1*0Sstevel@tonic-gate#./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate eval { my $q = pack "q", 0 }; 5*0Sstevel@tonic-gate if ($@) { 6*0Sstevel@tonic-gate print "1..0 # Skip: no 64-bit types\n"; 7*0Sstevel@tonic-gate exit(0); 8*0Sstevel@tonic-gate } 9*0Sstevel@tonic-gate chdir 't' if -d 't'; 10*0Sstevel@tonic-gate @INC = '../lib'; 11*0Sstevel@tonic-gate} 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate# This could use many more tests. 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gate# so that using > 0xfffffff constants and 16*0Sstevel@tonic-gate# 32+ bit integers don't cause noise 17*0Sstevel@tonic-gateuse warnings; 18*0Sstevel@tonic-gateno warnings qw(overflow portable); 19*0Sstevel@tonic-gate 20*0Sstevel@tonic-gateprint "1..67\n"; 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gate# as 6 * 6 = 36, the last digit of 6**n will always be six. Hence the last 23*0Sstevel@tonic-gate# digit of 16**n will always be six. Hence 16**n - 1 will always end in 5. 24*0Sstevel@tonic-gate# Assumption is that UVs will always be a multiple of 4 bits long. 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gatemy $UV_max = ~0; 27*0Sstevel@tonic-gatedie "UV_max eq '$UV_max', doesn't end in 5; your UV isn't 4n bits long :-(." 28*0Sstevel@tonic-gate unless $UV_max =~ /5$/; 29*0Sstevel@tonic-gatemy $UV_max_less3 = $UV_max - 3; 30*0Sstevel@tonic-gatemy $maths_preserves_UVs = $UV_max_less3 =~ /^\d+2$/; # 5 - 3 is 2. 31*0Sstevel@tonic-gateif ($maths_preserves_UVs) { 32*0Sstevel@tonic-gate print "# This perl's maths preserves all bits of a UV.\n"; 33*0Sstevel@tonic-gate} else { 34*0Sstevel@tonic-gate print "# This perl's maths does not preserve all bits of a UV.\n"; 35*0Sstevel@tonic-gate} 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gatemy $q = 12345678901; 38*0Sstevel@tonic-gatemy $r = 23456789012; 39*0Sstevel@tonic-gatemy $f = 0xffffffff; 40*0Sstevel@tonic-gatemy $x; 41*0Sstevel@tonic-gatemy $y; 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate$x = unpack "q", pack "q", $q; 44*0Sstevel@tonic-gateprint "not " unless $x == $q && $x > $f; 45*0Sstevel@tonic-gateprint "ok 1\n"; 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate$x = sprintf("%lld", 12345678901); 49*0Sstevel@tonic-gateprint "not " unless $x eq $q && $x > $f; 50*0Sstevel@tonic-gateprint "ok 2\n"; 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate$x = sprintf("%lld", $q); 54*0Sstevel@tonic-gateprint "not " unless $x == $q && $x eq $q && $x > $f; 55*0Sstevel@tonic-gateprint "ok 3\n"; 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate$x = sprintf("%Ld", $q); 58*0Sstevel@tonic-gateprint "not " unless $x == $q && $x eq $q && $x > $f; 59*0Sstevel@tonic-gateprint "ok 4\n"; 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate$x = sprintf("%qd", $q); 62*0Sstevel@tonic-gateprint "not " unless $x == $q && $x eq $q && $x > $f; 63*0Sstevel@tonic-gateprint "ok 5\n"; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate$x = sprintf("%llx", $q); 67*0Sstevel@tonic-gateprint "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f; 68*0Sstevel@tonic-gateprint "ok 6\n"; 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate$x = sprintf("%Lx", $q); 71*0Sstevel@tonic-gateprint "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f; 72*0Sstevel@tonic-gateprint "ok 7\n"; 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate$x = sprintf("%qx", $q); 75*0Sstevel@tonic-gateprint "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f; 76*0Sstevel@tonic-gateprint "ok 8\n"; 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate$x = sprintf("%llo", $q); 80*0Sstevel@tonic-gateprint "not " unless oct("0$x") == 0133767016065 && oct($x) > $f; 81*0Sstevel@tonic-gateprint "ok 9\n"; 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate$x = sprintf("%Lo", $q); 84*0Sstevel@tonic-gateprint "not " unless oct("0$x") == 0133767016065 && oct($x) > $f; 85*0Sstevel@tonic-gateprint "ok 10\n"; 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate$x = sprintf("%qo", $q); 88*0Sstevel@tonic-gateprint "not " unless oct("0$x") == 0133767016065 && oct($x) > $f; 89*0Sstevel@tonic-gateprint "ok 11\n"; 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate$x = sprintf("%llb", $q); 93*0Sstevel@tonic-gateprint "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 && 94*0Sstevel@tonic-gate oct("0b$x") > $f; 95*0Sstevel@tonic-gateprint "ok 12\n"; 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate$x = sprintf("%Lb", $q); 98*0Sstevel@tonic-gateprint "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 && 99*0Sstevel@tonic-gate oct("0b$x") > $f; 100*0Sstevel@tonic-gateprint "ok 13\n"; 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate$x = sprintf("%qb", $q); 103*0Sstevel@tonic-gateprint "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 && 104*0Sstevel@tonic-gate oct("0b$x") > $f; 105*0Sstevel@tonic-gateprint "ok 14\n"; 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate$x = sprintf("%llu", $q); 109*0Sstevel@tonic-gateprint "not " unless $x eq $q && $x > $f; 110*0Sstevel@tonic-gateprint "ok 15\n"; 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate$x = sprintf("%Lu", $q); 113*0Sstevel@tonic-gateprint "not " unless $x == $q && $x eq $q && $x > $f; 114*0Sstevel@tonic-gateprint "ok 16\n"; 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate$x = sprintf("%qu", $q); 117*0Sstevel@tonic-gateprint "not " unless $x == $q && $x eq $q && $x > $f; 118*0Sstevel@tonic-gateprint "ok 17\n"; 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate$x = sprintf("%D", $q); 122*0Sstevel@tonic-gateprint "not " unless $x == $q && $x eq $q && $x > $f; 123*0Sstevel@tonic-gateprint "ok 18\n"; 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate$x = sprintf("%U", $q); 126*0Sstevel@tonic-gateprint "not " unless $x == $q && $x eq $q && $x > $f; 127*0Sstevel@tonic-gateprint "ok 19\n"; 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate$x = sprintf("%O", $q); 130*0Sstevel@tonic-gateprint "not " unless oct($x) == $q && oct($x) > $f; 131*0Sstevel@tonic-gateprint "ok 20\n"; 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate$x = $q + $r; 135*0Sstevel@tonic-gateprint "not " unless $x == 35802467913 && $x > $f; 136*0Sstevel@tonic-gateprint "ok 21\n"; 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate$x = $q - $r; 139*0Sstevel@tonic-gateprint "not " unless $x == -11111110111 && -$x > $f; 140*0Sstevel@tonic-gateprint "ok 22\n"; 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gateif ($^O ne 'unicos') { 143*0Sstevel@tonic-gate $x = $q * 1234567; 144*0Sstevel@tonic-gate print "not " unless $x == 15241567763770867 && $x > $f; 145*0Sstevel@tonic-gate print "ok 23\n"; 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gate $x /= 1234567; 148*0Sstevel@tonic-gate print "not " unless $x == $q && $x > $f; 149*0Sstevel@tonic-gate print "ok 24\n"; 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate $x = 98765432109 % 12345678901; 152*0Sstevel@tonic-gate print "not " unless $x == 901; 153*0Sstevel@tonic-gate print "ok 25\n"; 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate # The following 12 tests adapted from op/inc. 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate $a = 9223372036854775807; 158*0Sstevel@tonic-gate $c = $a++; 159*0Sstevel@tonic-gate print "not " unless $a == 9223372036854775808; 160*0Sstevel@tonic-gate print "ok 26\n"; 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate $a = 9223372036854775807; 163*0Sstevel@tonic-gate $c = ++$a; 164*0Sstevel@tonic-gate print "not " 165*0Sstevel@tonic-gate unless $a == 9223372036854775808 && $c == $a; 166*0Sstevel@tonic-gate print "ok 27\n"; 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate $a = 9223372036854775807; 169*0Sstevel@tonic-gate $c = $a + 1; 170*0Sstevel@tonic-gate print "not " 171*0Sstevel@tonic-gate unless $a == 9223372036854775807 && $c == 9223372036854775808; 172*0Sstevel@tonic-gate print "ok 28\n"; 173*0Sstevel@tonic-gate 174*0Sstevel@tonic-gate $a = -9223372036854775808; 175*0Sstevel@tonic-gate $c = $a--; 176*0Sstevel@tonic-gate print "not " 177*0Sstevel@tonic-gate unless $a == -9223372036854775809 && $c == -9223372036854775808; 178*0Sstevel@tonic-gate print "ok 29\n"; 179*0Sstevel@tonic-gate 180*0Sstevel@tonic-gate $a = -9223372036854775808; 181*0Sstevel@tonic-gate $c = --$a; 182*0Sstevel@tonic-gate print "not " 183*0Sstevel@tonic-gate unless $a == -9223372036854775809 && $c == $a; 184*0Sstevel@tonic-gate print "ok 30\n"; 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate $a = -9223372036854775808; 187*0Sstevel@tonic-gate $c = $a - 1; 188*0Sstevel@tonic-gate print "not " 189*0Sstevel@tonic-gate unless $a == -9223372036854775808 && $c == -9223372036854775809; 190*0Sstevel@tonic-gate print "ok 31\n"; 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate $a = 9223372036854775808; 193*0Sstevel@tonic-gate $a = -$a; 194*0Sstevel@tonic-gate $c = $a--; 195*0Sstevel@tonic-gate print "not " 196*0Sstevel@tonic-gate unless $a == -9223372036854775809 && $c == -9223372036854775808; 197*0Sstevel@tonic-gate print "ok 32\n"; 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate $a = 9223372036854775808; 200*0Sstevel@tonic-gate $a = -$a; 201*0Sstevel@tonic-gate $c = --$a; 202*0Sstevel@tonic-gate print "not " 203*0Sstevel@tonic-gate unless $a == -9223372036854775809 && $c == $a; 204*0Sstevel@tonic-gate print "ok 33\n"; 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate $a = 9223372036854775808; 207*0Sstevel@tonic-gate $a = -$a; 208*0Sstevel@tonic-gate $c = $a - 1; 209*0Sstevel@tonic-gate print "not " 210*0Sstevel@tonic-gate unless $a == -9223372036854775808 && $c == -9223372036854775809; 211*0Sstevel@tonic-gate print "ok 34\n"; 212*0Sstevel@tonic-gate 213*0Sstevel@tonic-gate $a = 9223372036854775808; 214*0Sstevel@tonic-gate $b = -$a; 215*0Sstevel@tonic-gate $c = $b--; 216*0Sstevel@tonic-gate print "not " 217*0Sstevel@tonic-gate unless $b == -$a-1 && $c == -$a; 218*0Sstevel@tonic-gate print "ok 35\n"; 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate $a = 9223372036854775808; 221*0Sstevel@tonic-gate $b = -$a; 222*0Sstevel@tonic-gate $c = --$b; 223*0Sstevel@tonic-gate print "not " 224*0Sstevel@tonic-gate unless $b == -$a-1 && $c == $b; 225*0Sstevel@tonic-gate print "ok 36\n"; 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gate $a = 9223372036854775808; 228*0Sstevel@tonic-gate $b = -$a; 229*0Sstevel@tonic-gate $b = $b - 1; 230*0Sstevel@tonic-gate print "not " 231*0Sstevel@tonic-gate unless $b == -(++$a); 232*0Sstevel@tonic-gate print "ok 37\n"; 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate} else { 235*0Sstevel@tonic-gate # Unicos has imprecise doubles (14 decimal digits or so), 236*0Sstevel@tonic-gate # especially if operating near the UV/IV limits the low-order bits 237*0Sstevel@tonic-gate # become mangled even by simple arithmetic operations. 238*0Sstevel@tonic-gate for (23..37) { 239*0Sstevel@tonic-gate print "ok $_ # skipped: too imprecise numbers\n"; 240*0Sstevel@tonic-gate } 241*0Sstevel@tonic-gate} 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate$x = ''; 245*0Sstevel@tonic-gateprint "not " unless (vec($x, 1, 64) = $q) == $q; 246*0Sstevel@tonic-gateprint "ok 38\n"; 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gateprint "not " unless vec($x, 1, 64) == $q && vec($x, 1, 64) > $f; 249*0Sstevel@tonic-gateprint "ok 39\n"; 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gateprint "not " unless vec($x, 0, 64) == 0 && vec($x, 2, 64) == 0; 252*0Sstevel@tonic-gateprint "ok 40\n"; 253*0Sstevel@tonic-gate 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gateprint "not " unless ~0 == 0xffffffffffffffff; 256*0Sstevel@tonic-gateprint "ok 41\n"; 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gateprint "not " unless (0xffffffff<<32) == 0xffffffff00000000; 259*0Sstevel@tonic-gateprint "ok 42\n"; 260*0Sstevel@tonic-gate 261*0Sstevel@tonic-gateprint "not " unless ((0xffffffff)<<32)>>32 == 0xffffffff; 262*0Sstevel@tonic-gateprint "ok 43\n"; 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gateprint "not " unless 1<<63 == 0x8000000000000000; 265*0Sstevel@tonic-gateprint "ok 44\n"; 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gateprint "not " unless (sprintf "%#Vx", 1<<63) eq '0x8000000000000000'; 268*0Sstevel@tonic-gateprint "ok 45\n"; 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gateprint "not " unless (0x8000000000000000 | 1) == 0x8000000000000001; 271*0Sstevel@tonic-gateprint "ok 46\n"; 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gateprint "not " 274*0Sstevel@tonic-gate unless (0xf000000000000000 & 0x8000000000000000) == 0x8000000000000000; 275*0Sstevel@tonic-gateprint "ok 47\n"; 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gateprint "not " 278*0Sstevel@tonic-gate unless (0xf000000000000000 ^ 0xfffffffffffffff0) == 0x0ffffffffffffff0; 279*0Sstevel@tonic-gateprint "ok 48\n"; 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gateprint "not " 283*0Sstevel@tonic-gate unless (sprintf "%b", ~0) eq 284*0Sstevel@tonic-gate '1111111111111111111111111111111111111111111111111111111111111111'; 285*0Sstevel@tonic-gateprint "ok 49\n"; 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gateprint "not " 288*0Sstevel@tonic-gate unless (sprintf "%64b", ~0) eq 289*0Sstevel@tonic-gate '1111111111111111111111111111111111111111111111111111111111111111'; 290*0Sstevel@tonic-gateprint "ok 50\n"; 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gateprint "not " unless (sprintf "%d", ~0>>1) eq '9223372036854775807'; 293*0Sstevel@tonic-gateprint "ok 51\n"; 294*0Sstevel@tonic-gate 295*0Sstevel@tonic-gateprint "not " unless (sprintf "%u", ~0) eq '18446744073709551615'; 296*0Sstevel@tonic-gateprint "ok 52\n"; 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate# If the 53..55 fail you have problems in the parser's string->int conversion, 299*0Sstevel@tonic-gate# see toke.c:scan_num(). 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gate$q = -9223372036854775808; 302*0Sstevel@tonic-gateprint "# $q ne\n# -9223372036854775808\nnot " unless "$q" eq "-9223372036854775808"; 303*0Sstevel@tonic-gateprint "ok 53\n"; 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate$q = 9223372036854775807; 306*0Sstevel@tonic-gateprint "# $q ne\n# 9223372036854775807\nnot " unless "$q" eq "9223372036854775807"; 307*0Sstevel@tonic-gateprint "ok 54\n"; 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate$q = 18446744073709551615; 310*0Sstevel@tonic-gateprint "# $q ne\n# 18446744073709551615\nnot " unless "$q" eq "18446744073709551615"; 311*0Sstevel@tonic-gateprint "ok 55\n"; 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gate# Test that sv_2nv then sv_2iv is the same as sv_2iv direct 314*0Sstevel@tonic-gate# fails if whatever Atol is defined as can't actually cope with >32 bits. 315*0Sstevel@tonic-gatemy $num = 4294967297; 316*0Sstevel@tonic-gatemy $string = "4294967297"; 317*0Sstevel@tonic-gate{ 318*0Sstevel@tonic-gate use integer; 319*0Sstevel@tonic-gate $num += 0; 320*0Sstevel@tonic-gate $string += 0; 321*0Sstevel@tonic-gate} 322*0Sstevel@tonic-gateif ($num eq $string) { 323*0Sstevel@tonic-gate print "ok 56\n"; 324*0Sstevel@tonic-gate} else { 325*0Sstevel@tonic-gate print "not ok 56 # \"$num\" ne \"$string\"\n"; 326*0Sstevel@tonic-gate} 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate# Test that sv_2nv then sv_2uv is the same as sv_2uv direct 329*0Sstevel@tonic-gate$num = 4294967297; 330*0Sstevel@tonic-gate$string = "4294967297"; 331*0Sstevel@tonic-gate$num &= 0; 332*0Sstevel@tonic-gate$string &= 0; 333*0Sstevel@tonic-gateif ($num eq $string) { 334*0Sstevel@tonic-gate print "ok 57\n"; 335*0Sstevel@tonic-gate} else { 336*0Sstevel@tonic-gate print "not ok 57 # \"$num\" ne \"$string\"\n"; 337*0Sstevel@tonic-gate} 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate$q = "18446744073709551616e0"; 340*0Sstevel@tonic-gate$q += 0; 341*0Sstevel@tonic-gateprint "# \"18446744073709551616e0\" += 0 gives $q\nnot " if "$q" eq "18446744073709551615"; 342*0Sstevel@tonic-gateprint "ok 58\n"; 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate# 0xFFFFFFFFFFFFFFFF == 1 * 3 * 5 * 17 * 257 * 641 * 65537 * 6700417' 345*0Sstevel@tonic-gate$q = 0xFFFFFFFFFFFFFFFF / 3; 346*0Sstevel@tonic-gateif ($q == 0x5555555555555555 and ($q != 0x5555555555555556 347*0Sstevel@tonic-gate or !$maths_preserves_UVs)) { 348*0Sstevel@tonic-gate print "ok 59\n"; 349*0Sstevel@tonic-gate} else { 350*0Sstevel@tonic-gate print "not ok 59 # 0xFFFFFFFFFFFFFFFF / 3 = $q\n"; 351*0Sstevel@tonic-gate print "# Should not be floating point\n" if $q =~ tr/e.//; 352*0Sstevel@tonic-gate} 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate$q = 0xFFFFFFFFFFFFFFFF % 0x5555555555555555; 355*0Sstevel@tonic-gateif ($q == 0) { 356*0Sstevel@tonic-gate print "ok 60\n"; 357*0Sstevel@tonic-gate} else { 358*0Sstevel@tonic-gate print "not ok 60 # 0xFFFFFFFFFFFFFFFF % 0x5555555555555555 => $q\n"; 359*0Sstevel@tonic-gate} 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate$q = 0xFFFFFFFFFFFFFFFF % 0xFFFFFFFFFFFFFFF0; 362*0Sstevel@tonic-gateif ($q == 0xF) { 363*0Sstevel@tonic-gate print "ok 61\n"; 364*0Sstevel@tonic-gate} else { 365*0Sstevel@tonic-gate print "not ok 61 # 0xFFFFFFFFFFFFFFFF % 0xFFFFFFFFFFFFFFF0 => $q\n"; 366*0Sstevel@tonic-gate} 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gate$q = 0x8000000000000000 % 9223372036854775807; 369*0Sstevel@tonic-gateif ($q == 1) { 370*0Sstevel@tonic-gate print "ok 62\n"; 371*0Sstevel@tonic-gate} else { 372*0Sstevel@tonic-gate print "not ok 62 # 0x8000000000000000 % 9223372036854775807 => $q\n"; 373*0Sstevel@tonic-gate} 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate$q = 0x8000000000000000 % -9223372036854775807; 376*0Sstevel@tonic-gateif ($q == -9223372036854775806) { 377*0Sstevel@tonic-gate print "ok 63\n"; 378*0Sstevel@tonic-gate} else { 379*0Sstevel@tonic-gate print "not ok 63 # 0x8000000000000000 % -9223372036854775807 => $q\n"; 380*0Sstevel@tonic-gate} 381*0Sstevel@tonic-gate 382*0Sstevel@tonic-gate{ 383*0Sstevel@tonic-gate use integer; 384*0Sstevel@tonic-gate $q = hex "0x123456789abcdef0"; 385*0Sstevel@tonic-gate if ($q == 0x123456789abcdef0 and $q != 0x123456789abcdef1) { 386*0Sstevel@tonic-gate print "ok 64\n"; 387*0Sstevel@tonic-gate } else { 388*0Sstevel@tonic-gate printf "not ok 64 # hex \"0x123456789abcdef0\" = $q (%X)\n", $q; 389*0Sstevel@tonic-gate print "# Should not be floating point\n" if $q =~ tr/e.//; 390*0Sstevel@tonic-gate } 391*0Sstevel@tonic-gate 392*0Sstevel@tonic-gate $q = oct "0x123456789abcdef0"; 393*0Sstevel@tonic-gate if ($q == 0x123456789abcdef0 and $q != 0x123456789abcdef1) { 394*0Sstevel@tonic-gate print "ok 65\n"; 395*0Sstevel@tonic-gate } else { 396*0Sstevel@tonic-gate printf "not ok 65 # oct \"0x123456789abcdef0\" = $q (%X)\n", $q; 397*0Sstevel@tonic-gate print "# Should not be floating point\n" if $q =~ tr/e.//; 398*0Sstevel@tonic-gate } 399*0Sstevel@tonic-gate 400*0Sstevel@tonic-gate $q = oct "765432176543217654321"; 401*0Sstevel@tonic-gate if ($q == 0765432176543217654321 and $q != 0765432176543217654322) { 402*0Sstevel@tonic-gate print "ok 66\n"; 403*0Sstevel@tonic-gate } else { 404*0Sstevel@tonic-gate printf "not ok 66 # oct \"765432176543217654321\" = $q (%o)\n", $q; 405*0Sstevel@tonic-gate print "# Should not be floating point\n" if $q =~ tr/e.//; 406*0Sstevel@tonic-gate } 407*0Sstevel@tonic-gate 408*0Sstevel@tonic-gate $q = oct "0b0101010101010101010101010101010101010101010101010101010101010101"; 409*0Sstevel@tonic-gate if ($q == 0x5555555555555555 and $q != 0x5555555555555556) { 410*0Sstevel@tonic-gate print "ok 67\n"; 411*0Sstevel@tonic-gate } else { 412*0Sstevel@tonic-gate printf "not ok 67 # oct \"0b0101010101010101010101010101010101010101010101010101010101010101\" = $q (%b)\n", $q; 413*0Sstevel@tonic-gate print "# Should not be floating point\n" if $q =~ tr/e.//; 414*0Sstevel@tonic-gate } 415*0Sstevel@tonic-gate} 416*0Sstevel@tonic-gate 417*0Sstevel@tonic-gate# eof 418