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