1--TEST-- 2Test & operator : 64bit long tests 3--SKIPIF-- 4<?php 5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); 6?> 7--FILE-- 8<?php 9 10define("MAX_64Bit", 9223372036854775807); 11define("MAX_32Bit", 2147483647); 12define("MIN_64Bit", -9223372036854775807 - 1); 13define("MIN_32Bit", -2147483647 - 1); 14 15$longVals = array( 16 MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, 17 MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, 18 MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 19); 20 21$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit); 22 23error_reporting(E_ERROR); 24 25foreach ($longVals as $longVal) { 26 foreach($otherVals as $otherVal) { 27 echo "--- testing: $longVal & $otherVal ---\n"; 28 var_dump($longVal&$otherVal); 29 } 30} 31 32foreach ($otherVals as $otherVal) { 33 foreach($longVals as $longVal) { 34 echo "--- testing: $otherVal & $longVal ---\n"; 35 var_dump($otherVal&$longVal); 36 } 37} 38 39?> 40--EXPECT-- 41--- testing: 9223372036854775807 & 0 --- 42int(0) 43--- testing: 9223372036854775807 & 1 --- 44int(1) 45--- testing: 9223372036854775807 & -1 --- 46int(9223372036854775807) 47--- testing: 9223372036854775807 & 7 --- 48int(7) 49--- testing: 9223372036854775807 & 9 --- 50int(9) 51--- testing: 9223372036854775807 & 65 --- 52int(65) 53--- testing: 9223372036854775807 & -44 --- 54int(9223372036854775764) 55--- testing: 9223372036854775807 & 2147483647 --- 56int(2147483647) 57--- testing: 9223372036854775807 & 9223372036854775807 --- 58int(9223372036854775807) 59--- testing: -9223372036854775808 & 0 --- 60int(0) 61--- testing: -9223372036854775808 & 1 --- 62int(0) 63--- testing: -9223372036854775808 & -1 --- 64int(-9223372036854775808) 65--- testing: -9223372036854775808 & 7 --- 66int(0) 67--- testing: -9223372036854775808 & 9 --- 68int(0) 69--- testing: -9223372036854775808 & 65 --- 70int(0) 71--- testing: -9223372036854775808 & -44 --- 72int(-9223372036854775808) 73--- testing: -9223372036854775808 & 2147483647 --- 74int(0) 75--- testing: -9223372036854775808 & 9223372036854775807 --- 76int(0) 77--- testing: 2147483647 & 0 --- 78int(0) 79--- testing: 2147483647 & 1 --- 80int(1) 81--- testing: 2147483647 & -1 --- 82int(2147483647) 83--- testing: 2147483647 & 7 --- 84int(7) 85--- testing: 2147483647 & 9 --- 86int(9) 87--- testing: 2147483647 & 65 --- 88int(65) 89--- testing: 2147483647 & -44 --- 90int(2147483604) 91--- testing: 2147483647 & 2147483647 --- 92int(2147483647) 93--- testing: 2147483647 & 9223372036854775807 --- 94int(2147483647) 95--- testing: -2147483648 & 0 --- 96int(0) 97--- testing: -2147483648 & 1 --- 98int(0) 99--- testing: -2147483648 & -1 --- 100int(-2147483648) 101--- testing: -2147483648 & 7 --- 102int(0) 103--- testing: -2147483648 & 9 --- 104int(0) 105--- testing: -2147483648 & 65 --- 106int(0) 107--- testing: -2147483648 & -44 --- 108int(-2147483648) 109--- testing: -2147483648 & 2147483647 --- 110int(0) 111--- testing: -2147483648 & 9223372036854775807 --- 112int(9223372034707292160) 113--- testing: 9223372034707292160 & 0 --- 114int(0) 115--- testing: 9223372034707292160 & 1 --- 116int(0) 117--- testing: 9223372034707292160 & -1 --- 118int(9223372034707292160) 119--- testing: 9223372034707292160 & 7 --- 120int(0) 121--- testing: 9223372034707292160 & 9 --- 122int(0) 123--- testing: 9223372034707292160 & 65 --- 124int(0) 125--- testing: 9223372034707292160 & -44 --- 126int(9223372034707292160) 127--- testing: 9223372034707292160 & 2147483647 --- 128int(0) 129--- testing: 9223372034707292160 & 9223372036854775807 --- 130int(9223372034707292160) 131--- testing: -9223372034707292160 & 0 --- 132int(0) 133--- testing: -9223372034707292160 & 1 --- 134int(0) 135--- testing: -9223372034707292160 & -1 --- 136int(-9223372034707292160) 137--- testing: -9223372034707292160 & 7 --- 138int(0) 139--- testing: -9223372034707292160 & 9 --- 140int(0) 141--- testing: -9223372034707292160 & 65 --- 142int(0) 143--- testing: -9223372034707292160 & -44 --- 144int(-9223372034707292160) 145--- testing: -9223372034707292160 & 2147483647 --- 146int(0) 147--- testing: -9223372034707292160 & 9223372036854775807 --- 148int(2147483648) 149--- testing: 2147483648 & 0 --- 150int(0) 151--- testing: 2147483648 & 1 --- 152int(0) 153--- testing: 2147483648 & -1 --- 154int(2147483648) 155--- testing: 2147483648 & 7 --- 156int(0) 157--- testing: 2147483648 & 9 --- 158int(0) 159--- testing: 2147483648 & 65 --- 160int(0) 161--- testing: 2147483648 & -44 --- 162int(2147483648) 163--- testing: 2147483648 & 2147483647 --- 164int(0) 165--- testing: 2147483648 & 9223372036854775807 --- 166int(2147483648) 167--- testing: -2147483649 & 0 --- 168int(0) 169--- testing: -2147483649 & 1 --- 170int(1) 171--- testing: -2147483649 & -1 --- 172int(-2147483649) 173--- testing: -2147483649 & 7 --- 174int(7) 175--- testing: -2147483649 & 9 --- 176int(9) 177--- testing: -2147483649 & 65 --- 178int(65) 179--- testing: -2147483649 & -44 --- 180int(-2147483692) 181--- testing: -2147483649 & 2147483647 --- 182int(2147483647) 183--- testing: -2147483649 & 9223372036854775807 --- 184int(9223372034707292159) 185--- testing: 4294967294 & 0 --- 186int(0) 187--- testing: 4294967294 & 1 --- 188int(0) 189--- testing: 4294967294 & -1 --- 190int(4294967294) 191--- testing: 4294967294 & 7 --- 192int(6) 193--- testing: 4294967294 & 9 --- 194int(8) 195--- testing: 4294967294 & 65 --- 196int(64) 197--- testing: 4294967294 & -44 --- 198int(4294967252) 199--- testing: 4294967294 & 2147483647 --- 200int(2147483646) 201--- testing: 4294967294 & 9223372036854775807 --- 202int(4294967294) 203--- testing: 4294967295 & 0 --- 204int(0) 205--- testing: 4294967295 & 1 --- 206int(1) 207--- testing: 4294967295 & -1 --- 208int(4294967295) 209--- testing: 4294967295 & 7 --- 210int(7) 211--- testing: 4294967295 & 9 --- 212int(9) 213--- testing: 4294967295 & 65 --- 214int(65) 215--- testing: 4294967295 & -44 --- 216int(4294967252) 217--- testing: 4294967295 & 2147483647 --- 218int(2147483647) 219--- testing: 4294967295 & 9223372036854775807 --- 220int(4294967295) 221--- testing: 4294967293 & 0 --- 222int(0) 223--- testing: 4294967293 & 1 --- 224int(1) 225--- testing: 4294967293 & -1 --- 226int(4294967293) 227--- testing: 4294967293 & 7 --- 228int(5) 229--- testing: 4294967293 & 9 --- 230int(9) 231--- testing: 4294967293 & 65 --- 232int(65) 233--- testing: 4294967293 & -44 --- 234int(4294967252) 235--- testing: 4294967293 & 2147483647 --- 236int(2147483645) 237--- testing: 4294967293 & 9223372036854775807 --- 238int(4294967293) 239--- testing: 9223372036854775806 & 0 --- 240int(0) 241--- testing: 9223372036854775806 & 1 --- 242int(0) 243--- testing: 9223372036854775806 & -1 --- 244int(9223372036854775806) 245--- testing: 9223372036854775806 & 7 --- 246int(6) 247--- testing: 9223372036854775806 & 9 --- 248int(8) 249--- testing: 9223372036854775806 & 65 --- 250int(64) 251--- testing: 9223372036854775806 & -44 --- 252int(9223372036854775764) 253--- testing: 9223372036854775806 & 2147483647 --- 254int(2147483646) 255--- testing: 9223372036854775806 & 9223372036854775807 --- 256int(9223372036854775806) 257--- testing: 9.2233720368548E+18 & 0 --- 258int(0) 259--- testing: 9.2233720368548E+18 & 1 --- 260int(0) 261--- testing: 9.2233720368548E+18 & -1 --- 262int(-9223372036854775808) 263--- testing: 9.2233720368548E+18 & 7 --- 264int(0) 265--- testing: 9.2233720368548E+18 & 9 --- 266int(0) 267--- testing: 9.2233720368548E+18 & 65 --- 268int(0) 269--- testing: 9.2233720368548E+18 & -44 --- 270int(-9223372036854775808) 271--- testing: 9.2233720368548E+18 & 2147483647 --- 272int(0) 273--- testing: 9.2233720368548E+18 & 9223372036854775807 --- 274int(0) 275--- testing: -9223372036854775807 & 0 --- 276int(0) 277--- testing: -9223372036854775807 & 1 --- 278int(1) 279--- testing: -9223372036854775807 & -1 --- 280int(-9223372036854775807) 281--- testing: -9223372036854775807 & 7 --- 282int(1) 283--- testing: -9223372036854775807 & 9 --- 284int(1) 285--- testing: -9223372036854775807 & 65 --- 286int(1) 287--- testing: -9223372036854775807 & -44 --- 288int(-9223372036854775808) 289--- testing: -9223372036854775807 & 2147483647 --- 290int(1) 291--- testing: -9223372036854775807 & 9223372036854775807 --- 292int(1) 293--- testing: -9.2233720368548E+18 & 0 --- 294int(0) 295--- testing: -9.2233720368548E+18 & 1 --- 296int(0) 297--- testing: -9.2233720368548E+18 & -1 --- 298int(-9223372036854775808) 299--- testing: -9.2233720368548E+18 & 7 --- 300int(0) 301--- testing: -9.2233720368548E+18 & 9 --- 302int(0) 303--- testing: -9.2233720368548E+18 & 65 --- 304int(0) 305--- testing: -9.2233720368548E+18 & -44 --- 306int(-9223372036854775808) 307--- testing: -9.2233720368548E+18 & 2147483647 --- 308int(0) 309--- testing: -9.2233720368548E+18 & 9223372036854775807 --- 310int(0) 311--- testing: 0 & 9223372036854775807 --- 312int(0) 313--- testing: 0 & -9223372036854775808 --- 314int(0) 315--- testing: 0 & 2147483647 --- 316int(0) 317--- testing: 0 & -2147483648 --- 318int(0) 319--- testing: 0 & 9223372034707292160 --- 320int(0) 321--- testing: 0 & -9223372034707292160 --- 322int(0) 323--- testing: 0 & 2147483648 --- 324int(0) 325--- testing: 0 & -2147483649 --- 326int(0) 327--- testing: 0 & 4294967294 --- 328int(0) 329--- testing: 0 & 4294967295 --- 330int(0) 331--- testing: 0 & 4294967293 --- 332int(0) 333--- testing: 0 & 9223372036854775806 --- 334int(0) 335--- testing: 0 & 9.2233720368548E+18 --- 336int(0) 337--- testing: 0 & -9223372036854775807 --- 338int(0) 339--- testing: 0 & -9.2233720368548E+18 --- 340int(0) 341--- testing: 1 & 9223372036854775807 --- 342int(1) 343--- testing: 1 & -9223372036854775808 --- 344int(0) 345--- testing: 1 & 2147483647 --- 346int(1) 347--- testing: 1 & -2147483648 --- 348int(0) 349--- testing: 1 & 9223372034707292160 --- 350int(0) 351--- testing: 1 & -9223372034707292160 --- 352int(0) 353--- testing: 1 & 2147483648 --- 354int(0) 355--- testing: 1 & -2147483649 --- 356int(1) 357--- testing: 1 & 4294967294 --- 358int(0) 359--- testing: 1 & 4294967295 --- 360int(1) 361--- testing: 1 & 4294967293 --- 362int(1) 363--- testing: 1 & 9223372036854775806 --- 364int(0) 365--- testing: 1 & 9.2233720368548E+18 --- 366int(0) 367--- testing: 1 & -9223372036854775807 --- 368int(1) 369--- testing: 1 & -9.2233720368548E+18 --- 370int(0) 371--- testing: -1 & 9223372036854775807 --- 372int(9223372036854775807) 373--- testing: -1 & -9223372036854775808 --- 374int(-9223372036854775808) 375--- testing: -1 & 2147483647 --- 376int(2147483647) 377--- testing: -1 & -2147483648 --- 378int(-2147483648) 379--- testing: -1 & 9223372034707292160 --- 380int(9223372034707292160) 381--- testing: -1 & -9223372034707292160 --- 382int(-9223372034707292160) 383--- testing: -1 & 2147483648 --- 384int(2147483648) 385--- testing: -1 & -2147483649 --- 386int(-2147483649) 387--- testing: -1 & 4294967294 --- 388int(4294967294) 389--- testing: -1 & 4294967295 --- 390int(4294967295) 391--- testing: -1 & 4294967293 --- 392int(4294967293) 393--- testing: -1 & 9223372036854775806 --- 394int(9223372036854775806) 395--- testing: -1 & 9.2233720368548E+18 --- 396int(-9223372036854775808) 397--- testing: -1 & -9223372036854775807 --- 398int(-9223372036854775807) 399--- testing: -1 & -9.2233720368548E+18 --- 400int(-9223372036854775808) 401--- testing: 7 & 9223372036854775807 --- 402int(7) 403--- testing: 7 & -9223372036854775808 --- 404int(0) 405--- testing: 7 & 2147483647 --- 406int(7) 407--- testing: 7 & -2147483648 --- 408int(0) 409--- testing: 7 & 9223372034707292160 --- 410int(0) 411--- testing: 7 & -9223372034707292160 --- 412int(0) 413--- testing: 7 & 2147483648 --- 414int(0) 415--- testing: 7 & -2147483649 --- 416int(7) 417--- testing: 7 & 4294967294 --- 418int(6) 419--- testing: 7 & 4294967295 --- 420int(7) 421--- testing: 7 & 4294967293 --- 422int(5) 423--- testing: 7 & 9223372036854775806 --- 424int(6) 425--- testing: 7 & 9.2233720368548E+18 --- 426int(0) 427--- testing: 7 & -9223372036854775807 --- 428int(1) 429--- testing: 7 & -9.2233720368548E+18 --- 430int(0) 431--- testing: 9 & 9223372036854775807 --- 432int(9) 433--- testing: 9 & -9223372036854775808 --- 434int(0) 435--- testing: 9 & 2147483647 --- 436int(9) 437--- testing: 9 & -2147483648 --- 438int(0) 439--- testing: 9 & 9223372034707292160 --- 440int(0) 441--- testing: 9 & -9223372034707292160 --- 442int(0) 443--- testing: 9 & 2147483648 --- 444int(0) 445--- testing: 9 & -2147483649 --- 446int(9) 447--- testing: 9 & 4294967294 --- 448int(8) 449--- testing: 9 & 4294967295 --- 450int(9) 451--- testing: 9 & 4294967293 --- 452int(9) 453--- testing: 9 & 9223372036854775806 --- 454int(8) 455--- testing: 9 & 9.2233720368548E+18 --- 456int(0) 457--- testing: 9 & -9223372036854775807 --- 458int(1) 459--- testing: 9 & -9.2233720368548E+18 --- 460int(0) 461--- testing: 65 & 9223372036854775807 --- 462int(65) 463--- testing: 65 & -9223372036854775808 --- 464int(0) 465--- testing: 65 & 2147483647 --- 466int(65) 467--- testing: 65 & -2147483648 --- 468int(0) 469--- testing: 65 & 9223372034707292160 --- 470int(0) 471--- testing: 65 & -9223372034707292160 --- 472int(0) 473--- testing: 65 & 2147483648 --- 474int(0) 475--- testing: 65 & -2147483649 --- 476int(65) 477--- testing: 65 & 4294967294 --- 478int(64) 479--- testing: 65 & 4294967295 --- 480int(65) 481--- testing: 65 & 4294967293 --- 482int(65) 483--- testing: 65 & 9223372036854775806 --- 484int(64) 485--- testing: 65 & 9.2233720368548E+18 --- 486int(0) 487--- testing: 65 & -9223372036854775807 --- 488int(1) 489--- testing: 65 & -9.2233720368548E+18 --- 490int(0) 491--- testing: -44 & 9223372036854775807 --- 492int(9223372036854775764) 493--- testing: -44 & -9223372036854775808 --- 494int(-9223372036854775808) 495--- testing: -44 & 2147483647 --- 496int(2147483604) 497--- testing: -44 & -2147483648 --- 498int(-2147483648) 499--- testing: -44 & 9223372034707292160 --- 500int(9223372034707292160) 501--- testing: -44 & -9223372034707292160 --- 502int(-9223372034707292160) 503--- testing: -44 & 2147483648 --- 504int(2147483648) 505--- testing: -44 & -2147483649 --- 506int(-2147483692) 507--- testing: -44 & 4294967294 --- 508int(4294967252) 509--- testing: -44 & 4294967295 --- 510int(4294967252) 511--- testing: -44 & 4294967293 --- 512int(4294967252) 513--- testing: -44 & 9223372036854775806 --- 514int(9223372036854775764) 515--- testing: -44 & 9.2233720368548E+18 --- 516int(-9223372036854775808) 517--- testing: -44 & -9223372036854775807 --- 518int(-9223372036854775808) 519--- testing: -44 & -9.2233720368548E+18 --- 520int(-9223372036854775808) 521--- testing: 2147483647 & 9223372036854775807 --- 522int(2147483647) 523--- testing: 2147483647 & -9223372036854775808 --- 524int(0) 525--- testing: 2147483647 & 2147483647 --- 526int(2147483647) 527--- testing: 2147483647 & -2147483648 --- 528int(0) 529--- testing: 2147483647 & 9223372034707292160 --- 530int(0) 531--- testing: 2147483647 & -9223372034707292160 --- 532int(0) 533--- testing: 2147483647 & 2147483648 --- 534int(0) 535--- testing: 2147483647 & -2147483649 --- 536int(2147483647) 537--- testing: 2147483647 & 4294967294 --- 538int(2147483646) 539--- testing: 2147483647 & 4294967295 --- 540int(2147483647) 541--- testing: 2147483647 & 4294967293 --- 542int(2147483645) 543--- testing: 2147483647 & 9223372036854775806 --- 544int(2147483646) 545--- testing: 2147483647 & 9.2233720368548E+18 --- 546int(0) 547--- testing: 2147483647 & -9223372036854775807 --- 548int(1) 549--- testing: 2147483647 & -9.2233720368548E+18 --- 550int(0) 551--- testing: 9223372036854775807 & 9223372036854775807 --- 552int(9223372036854775807) 553--- testing: 9223372036854775807 & -9223372036854775808 --- 554int(0) 555--- testing: 9223372036854775807 & 2147483647 --- 556int(2147483647) 557--- testing: 9223372036854775807 & -2147483648 --- 558int(9223372034707292160) 559--- testing: 9223372036854775807 & 9223372034707292160 --- 560int(9223372034707292160) 561--- testing: 9223372036854775807 & -9223372034707292160 --- 562int(2147483648) 563--- testing: 9223372036854775807 & 2147483648 --- 564int(2147483648) 565--- testing: 9223372036854775807 & -2147483649 --- 566int(9223372034707292159) 567--- testing: 9223372036854775807 & 4294967294 --- 568int(4294967294) 569--- testing: 9223372036854775807 & 4294967295 --- 570int(4294967295) 571--- testing: 9223372036854775807 & 4294967293 --- 572int(4294967293) 573--- testing: 9223372036854775807 & 9223372036854775806 --- 574int(9223372036854775806) 575--- testing: 9223372036854775807 & 9.2233720368548E+18 --- 576int(0) 577--- testing: 9223372036854775807 & -9223372036854775807 --- 578int(1) 579--- testing: 9223372036854775807 & -9.2233720368548E+18 --- 580int(0) 581