bitwiseShiftLeft_variationStr_64bit.phpt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. --TEST--
  2. Test << operator : various numbers as strings
  3. --SKIPIF--
  4. <?php
  5. if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
  6. if (strtolower(php_uname('m')) != 'x86_64') die("skip this test is for x86_64 platforms only");
  7. ?>
  8. --FILE--
  9. <?php
  10. $strVals = array(
  11. "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
  12. "a5.9"
  13. );
  14. error_reporting(E_ERROR);
  15. foreach ($strVals as $strVal) {
  16. foreach($strVals as $otherVal) {
  17. echo "--- testing: '$strVal' << '$otherVal' ---\n";
  18. var_dump(bin2hex($strVal<<$otherVal));
  19. }
  20. }
  21. ?>
  22. ===DONE===
  23. --EXPECT--
  24. --- testing: '0' << '0' ---
  25. string(2) "30"
  26. --- testing: '0' << '65' ---
  27. string(2) "30"
  28. --- testing: '0' << '-44' ---
  29. string(2) "30"
  30. --- testing: '0' << '1.2' ---
  31. string(2) "30"
  32. --- testing: '0' << '-7.7' ---
  33. string(2) "30"
  34. --- testing: '0' << 'abc' ---
  35. string(2) "30"
  36. --- testing: '0' << '123abc' ---
  37. string(2) "30"
  38. --- testing: '0' << '123e5' ---
  39. string(2) "30"
  40. --- testing: '0' << '123e5xyz' ---
  41. string(2) "30"
  42. --- testing: '0' << ' 123abc' ---
  43. string(2) "30"
  44. --- testing: '0' << '123 abc' ---
  45. string(2) "30"
  46. --- testing: '0' << '123abc ' ---
  47. string(2) "30"
  48. --- testing: '0' << '3.4a' ---
  49. string(2) "30"
  50. --- testing: '0' << 'a5.9' ---
  51. string(2) "30"
  52. --- testing: '65' << '0' ---
  53. string(4) "3635"
  54. --- testing: '65' << '65' ---
  55. string(6) "313330"
  56. --- testing: '65' << '-44' ---
  57. string(16) "3638313537343430"
  58. --- testing: '65' << '1.2' ---
  59. string(6) "313330"
  60. --- testing: '65' << '-7.7' ---
  61. string(40) "2d39303739323536383438373738393139393336"
  62. --- testing: '65' << 'abc' ---
  63. string(4) "3635"
  64. --- testing: '65' << '123abc' ---
  65. string(36) "353736343630373532333033343233343838"
  66. --- testing: '65' << '123e5' ---
  67. string(36) "353736343630373532333033343233343838"
  68. --- testing: '65' << '123e5xyz' ---
  69. string(36) "353736343630373532333033343233343838"
  70. --- testing: '65' << ' 123abc' ---
  71. string(36) "353736343630373532333033343233343838"
  72. --- testing: '65' << '123 abc' ---
  73. string(36) "353736343630373532333033343233343838"
  74. --- testing: '65' << '123abc ' ---
  75. string(36) "353736343630373532333033343233343838"
  76. --- testing: '65' << '3.4a' ---
  77. string(6) "353230"
  78. --- testing: '65' << 'a5.9' ---
  79. string(4) "3635"
  80. --- testing: '-44' << '0' ---
  81. string(6) "2d3434"
  82. --- testing: '-44' << '65' ---
  83. string(6) "2d3838"
  84. --- testing: '-44' << '-44' ---
  85. string(18) "2d3436313337333434"
  86. --- testing: '-44' << '1.2' ---
  87. string(6) "2d3838"
  88. --- testing: '-44' << '-7.7' ---
  89. string(40) "2d36333431303638323735333337363538333638"
  90. --- testing: '-44' << 'abc' ---
  91. string(6) "2d3434"
  92. --- testing: '-44' << '123abc' ---
  93. string(40) "2d36393137353239303237363431303831383536"
  94. --- testing: '-44' << '123e5' ---
  95. string(40) "2d36393137353239303237363431303831383536"
  96. --- testing: '-44' << '123e5xyz' ---
  97. string(40) "2d36393137353239303237363431303831383536"
  98. --- testing: '-44' << ' 123abc' ---
  99. string(40) "2d36393137353239303237363431303831383536"
  100. --- testing: '-44' << '123 abc' ---
  101. string(40) "2d36393137353239303237363431303831383536"
  102. --- testing: '-44' << '123abc ' ---
  103. string(40) "2d36393137353239303237363431303831383536"
  104. --- testing: '-44' << '3.4a' ---
  105. string(8) "2d333532"
  106. --- testing: '-44' << 'a5.9' ---
  107. string(6) "2d3434"
  108. --- testing: '1.2' << '0' ---
  109. string(2) "31"
  110. --- testing: '1.2' << '65' ---
  111. string(2) "32"
  112. --- testing: '1.2' << '-44' ---
  113. string(14) "31303438353736"
  114. --- testing: '1.2' << '1.2' ---
  115. string(2) "32"
  116. --- testing: '1.2' << '-7.7' ---
  117. string(36) "313434313135313838303735383535383732"
  118. --- testing: '1.2' << 'abc' ---
  119. string(2) "31"
  120. --- testing: '1.2' << '123abc' ---
  121. string(36) "353736343630373532333033343233343838"
  122. --- testing: '1.2' << '123e5' ---
  123. string(36) "353736343630373532333033343233343838"
  124. --- testing: '1.2' << '123e5xyz' ---
  125. string(36) "353736343630373532333033343233343838"
  126. --- testing: '1.2' << ' 123abc' ---
  127. string(36) "353736343630373532333033343233343838"
  128. --- testing: '1.2' << '123 abc' ---
  129. string(36) "353736343630373532333033343233343838"
  130. --- testing: '1.2' << '123abc ' ---
  131. string(36) "353736343630373532333033343233343838"
  132. --- testing: '1.2' << '3.4a' ---
  133. string(2) "38"
  134. --- testing: '1.2' << 'a5.9' ---
  135. string(2) "31"
  136. --- testing: '-7.7' << '0' ---
  137. string(4) "2d37"
  138. --- testing: '-7.7' << '65' ---
  139. string(6) "2d3134"
  140. --- testing: '-7.7' << '-44' ---
  141. string(16) "2d37333430303332"
  142. --- testing: '-7.7' << '1.2' ---
  143. string(6) "2d3134"
  144. --- testing: '-7.7' << '-7.7' ---
  145. string(40) "2d31303038383036333136353330393931313034"
  146. --- testing: '-7.7' << 'abc' ---
  147. string(4) "2d37"
  148. --- testing: '-7.7' << '123abc' ---
  149. string(40) "2d34303335323235323636313233393634343136"
  150. --- testing: '-7.7' << '123e5' ---
  151. string(40) "2d34303335323235323636313233393634343136"
  152. --- testing: '-7.7' << '123e5xyz' ---
  153. string(40) "2d34303335323235323636313233393634343136"
  154. --- testing: '-7.7' << ' 123abc' ---
  155. string(40) "2d34303335323235323636313233393634343136"
  156. --- testing: '-7.7' << '123 abc' ---
  157. string(40) "2d34303335323235323636313233393634343136"
  158. --- testing: '-7.7' << '123abc ' ---
  159. string(40) "2d34303335323235323636313233393634343136"
  160. --- testing: '-7.7' << '3.4a' ---
  161. string(6) "2d3536"
  162. --- testing: '-7.7' << 'a5.9' ---
  163. string(4) "2d37"
  164. --- testing: 'abc' << '0' ---
  165. string(2) "30"
  166. --- testing: 'abc' << '65' ---
  167. string(2) "30"
  168. --- testing: 'abc' << '-44' ---
  169. string(2) "30"
  170. --- testing: 'abc' << '1.2' ---
  171. string(2) "30"
  172. --- testing: 'abc' << '-7.7' ---
  173. string(2) "30"
  174. --- testing: 'abc' << 'abc' ---
  175. string(2) "30"
  176. --- testing: 'abc' << '123abc' ---
  177. string(2) "30"
  178. --- testing: 'abc' << '123e5' ---
  179. string(2) "30"
  180. --- testing: 'abc' << '123e5xyz' ---
  181. string(2) "30"
  182. --- testing: 'abc' << ' 123abc' ---
  183. string(2) "30"
  184. --- testing: 'abc' << '123 abc' ---
  185. string(2) "30"
  186. --- testing: 'abc' << '123abc ' ---
  187. string(2) "30"
  188. --- testing: 'abc' << '3.4a' ---
  189. string(2) "30"
  190. --- testing: 'abc' << 'a5.9' ---
  191. string(2) "30"
  192. --- testing: '123abc' << '0' ---
  193. string(6) "313233"
  194. --- testing: '123abc' << '65' ---
  195. string(6) "323436"
  196. --- testing: '123abc' << '-44' ---
  197. string(18) "313238393734383438"
  198. --- testing: '123abc' << '1.2' ---
  199. string(6) "323436"
  200. --- testing: '123abc' << '-7.7' ---
  201. string(38) "2d373230353735393430333739323739333630"
  202. --- testing: '123abc' << 'abc' ---
  203. string(6) "313233"
  204. --- testing: '123abc' << '123abc' ---
  205. string(40) "2d32383832333033373631353137313137343430"
  206. --- testing: '123abc' << '123e5' ---
  207. string(40) "2d32383832333033373631353137313137343430"
  208. --- testing: '123abc' << '123e5xyz' ---
  209. string(40) "2d32383832333033373631353137313137343430"
  210. --- testing: '123abc' << ' 123abc' ---
  211. string(40) "2d32383832333033373631353137313137343430"
  212. --- testing: '123abc' << '123 abc' ---
  213. string(40) "2d32383832333033373631353137313137343430"
  214. --- testing: '123abc' << '123abc ' ---
  215. string(40) "2d32383832333033373631353137313137343430"
  216. --- testing: '123abc' << '3.4a' ---
  217. string(6) "393834"
  218. --- testing: '123abc' << 'a5.9' ---
  219. string(6) "313233"
  220. --- testing: '123e5' << '0' ---
  221. string(6) "313233"
  222. --- testing: '123e5' << '65' ---
  223. string(6) "323436"
  224. --- testing: '123e5' << '-44' ---
  225. string(18) "313238393734383438"
  226. --- testing: '123e5' << '1.2' ---
  227. string(6) "323436"
  228. --- testing: '123e5' << '-7.7' ---
  229. string(38) "2d373230353735393430333739323739333630"
  230. --- testing: '123e5' << 'abc' ---
  231. string(6) "313233"
  232. --- testing: '123e5' << '123abc' ---
  233. string(40) "2d32383832333033373631353137313137343430"
  234. --- testing: '123e5' << '123e5' ---
  235. string(40) "2d32383832333033373631353137313137343430"
  236. --- testing: '123e5' << '123e5xyz' ---
  237. string(40) "2d32383832333033373631353137313137343430"
  238. --- testing: '123e5' << ' 123abc' ---
  239. string(40) "2d32383832333033373631353137313137343430"
  240. --- testing: '123e5' << '123 abc' ---
  241. string(40) "2d32383832333033373631353137313137343430"
  242. --- testing: '123e5' << '123abc ' ---
  243. string(40) "2d32383832333033373631353137313137343430"
  244. --- testing: '123e5' << '3.4a' ---
  245. string(6) "393834"
  246. --- testing: '123e5' << 'a5.9' ---
  247. string(6) "313233"
  248. --- testing: '123e5xyz' << '0' ---
  249. string(6) "313233"
  250. --- testing: '123e5xyz' << '65' ---
  251. string(6) "323436"
  252. --- testing: '123e5xyz' << '-44' ---
  253. string(18) "313238393734383438"
  254. --- testing: '123e5xyz' << '1.2' ---
  255. string(6) "323436"
  256. --- testing: '123e5xyz' << '-7.7' ---
  257. string(38) "2d373230353735393430333739323739333630"
  258. --- testing: '123e5xyz' << 'abc' ---
  259. string(6) "313233"
  260. --- testing: '123e5xyz' << '123abc' ---
  261. string(40) "2d32383832333033373631353137313137343430"
  262. --- testing: '123e5xyz' << '123e5' ---
  263. string(40) "2d32383832333033373631353137313137343430"
  264. --- testing: '123e5xyz' << '123e5xyz' ---
  265. string(40) "2d32383832333033373631353137313137343430"
  266. --- testing: '123e5xyz' << ' 123abc' ---
  267. string(40) "2d32383832333033373631353137313137343430"
  268. --- testing: '123e5xyz' << '123 abc' ---
  269. string(40) "2d32383832333033373631353137313137343430"
  270. --- testing: '123e5xyz' << '123abc ' ---
  271. string(40) "2d32383832333033373631353137313137343430"
  272. --- testing: '123e5xyz' << '3.4a' ---
  273. string(6) "393834"
  274. --- testing: '123e5xyz' << 'a5.9' ---
  275. string(6) "313233"
  276. --- testing: ' 123abc' << '0' ---
  277. string(6) "313233"
  278. --- testing: ' 123abc' << '65' ---
  279. string(6) "323436"
  280. --- testing: ' 123abc' << '-44' ---
  281. string(18) "313238393734383438"
  282. --- testing: ' 123abc' << '1.2' ---
  283. string(6) "323436"
  284. --- testing: ' 123abc' << '-7.7' ---
  285. string(38) "2d373230353735393430333739323739333630"
  286. --- testing: ' 123abc' << 'abc' ---
  287. string(6) "313233"
  288. --- testing: ' 123abc' << '123abc' ---
  289. string(40) "2d32383832333033373631353137313137343430"
  290. --- testing: ' 123abc' << '123e5' ---
  291. string(40) "2d32383832333033373631353137313137343430"
  292. --- testing: ' 123abc' << '123e5xyz' ---
  293. string(40) "2d32383832333033373631353137313137343430"
  294. --- testing: ' 123abc' << ' 123abc' ---
  295. string(40) "2d32383832333033373631353137313137343430"
  296. --- testing: ' 123abc' << '123 abc' ---
  297. string(40) "2d32383832333033373631353137313137343430"
  298. --- testing: ' 123abc' << '123abc ' ---
  299. string(40) "2d32383832333033373631353137313137343430"
  300. --- testing: ' 123abc' << '3.4a' ---
  301. string(6) "393834"
  302. --- testing: ' 123abc' << 'a5.9' ---
  303. string(6) "313233"
  304. --- testing: '123 abc' << '0' ---
  305. string(6) "313233"
  306. --- testing: '123 abc' << '65' ---
  307. string(6) "323436"
  308. --- testing: '123 abc' << '-44' ---
  309. string(18) "313238393734383438"
  310. --- testing: '123 abc' << '1.2' ---
  311. string(6) "323436"
  312. --- testing: '123 abc' << '-7.7' ---
  313. string(38) "2d373230353735393430333739323739333630"
  314. --- testing: '123 abc' << 'abc' ---
  315. string(6) "313233"
  316. --- testing: '123 abc' << '123abc' ---
  317. string(40) "2d32383832333033373631353137313137343430"
  318. --- testing: '123 abc' << '123e5' ---
  319. string(40) "2d32383832333033373631353137313137343430"
  320. --- testing: '123 abc' << '123e5xyz' ---
  321. string(40) "2d32383832333033373631353137313137343430"
  322. --- testing: '123 abc' << ' 123abc' ---
  323. string(40) "2d32383832333033373631353137313137343430"
  324. --- testing: '123 abc' << '123 abc' ---
  325. string(40) "2d32383832333033373631353137313137343430"
  326. --- testing: '123 abc' << '123abc ' ---
  327. string(40) "2d32383832333033373631353137313137343430"
  328. --- testing: '123 abc' << '3.4a' ---
  329. string(6) "393834"
  330. --- testing: '123 abc' << 'a5.9' ---
  331. string(6) "313233"
  332. --- testing: '123abc ' << '0' ---
  333. string(6) "313233"
  334. --- testing: '123abc ' << '65' ---
  335. string(6) "323436"
  336. --- testing: '123abc ' << '-44' ---
  337. string(18) "313238393734383438"
  338. --- testing: '123abc ' << '1.2' ---
  339. string(6) "323436"
  340. --- testing: '123abc ' << '-7.7' ---
  341. string(38) "2d373230353735393430333739323739333630"
  342. --- testing: '123abc ' << 'abc' ---
  343. string(6) "313233"
  344. --- testing: '123abc ' << '123abc' ---
  345. string(40) "2d32383832333033373631353137313137343430"
  346. --- testing: '123abc ' << '123e5' ---
  347. string(40) "2d32383832333033373631353137313137343430"
  348. --- testing: '123abc ' << '123e5xyz' ---
  349. string(40) "2d32383832333033373631353137313137343430"
  350. --- testing: '123abc ' << ' 123abc' ---
  351. string(40) "2d32383832333033373631353137313137343430"
  352. --- testing: '123abc ' << '123 abc' ---
  353. string(40) "2d32383832333033373631353137313137343430"
  354. --- testing: '123abc ' << '123abc ' ---
  355. string(40) "2d32383832333033373631353137313137343430"
  356. --- testing: '123abc ' << '3.4a' ---
  357. string(6) "393834"
  358. --- testing: '123abc ' << 'a5.9' ---
  359. string(6) "313233"
  360. --- testing: '3.4a' << '0' ---
  361. string(2) "33"
  362. --- testing: '3.4a' << '65' ---
  363. string(2) "36"
  364. --- testing: '3.4a' << '-44' ---
  365. string(14) "33313435373238"
  366. --- testing: '3.4a' << '1.2' ---
  367. string(2) "36"
  368. --- testing: '3.4a' << '-7.7' ---
  369. string(36) "343332333435353634323237353637363136"
  370. --- testing: '3.4a' << 'abc' ---
  371. string(2) "33"
  372. --- testing: '3.4a' << '123abc' ---
  373. string(38) "31373239333832323536393130323730343634"
  374. --- testing: '3.4a' << '123e5' ---
  375. string(38) "31373239333832323536393130323730343634"
  376. --- testing: '3.4a' << '123e5xyz' ---
  377. string(38) "31373239333832323536393130323730343634"
  378. --- testing: '3.4a' << ' 123abc' ---
  379. string(38) "31373239333832323536393130323730343634"
  380. --- testing: '3.4a' << '123 abc' ---
  381. string(38) "31373239333832323536393130323730343634"
  382. --- testing: '3.4a' << '123abc ' ---
  383. string(38) "31373239333832323536393130323730343634"
  384. --- testing: '3.4a' << '3.4a' ---
  385. string(4) "3234"
  386. --- testing: '3.4a' << 'a5.9' ---
  387. string(2) "33"
  388. --- testing: 'a5.9' << '0' ---
  389. string(2) "30"
  390. --- testing: 'a5.9' << '65' ---
  391. string(2) "30"
  392. --- testing: 'a5.9' << '-44' ---
  393. string(2) "30"
  394. --- testing: 'a5.9' << '1.2' ---
  395. string(2) "30"
  396. --- testing: 'a5.9' << '-7.7' ---
  397. string(2) "30"
  398. --- testing: 'a5.9' << 'abc' ---
  399. string(2) "30"
  400. --- testing: 'a5.9' << '123abc' ---
  401. string(2) "30"
  402. --- testing: 'a5.9' << '123e5' ---
  403. string(2) "30"
  404. --- testing: 'a5.9' << '123e5xyz' ---
  405. string(2) "30"
  406. --- testing: 'a5.9' << ' 123abc' ---
  407. string(2) "30"
  408. --- testing: 'a5.9' << '123 abc' ---
  409. string(2) "30"
  410. --- testing: 'a5.9' << '123abc ' ---
  411. string(2) "30"
  412. --- testing: 'a5.9' << '3.4a' ---
  413. string(2) "30"
  414. --- testing: 'a5.9' << 'a5.9' ---
  415. string(2) "30"
  416. ===DONE===