003.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Check for number base recognition
  3. --SKIPIF--
  4. <?php if (!extension_loaded("gmp")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. /* Binary */
  8. $test[] = gmp_init("0b10011010010");
  9. $test[] = gmp_init("0b10011010010", 2);
  10. $test[] = gmp_init("10011010010");
  11. $test[] = gmp_init("10011010010", 2);
  12. /* Octal */
  13. $test[] = gmp_init("02322");
  14. $test[] = gmp_init("02322", 8);
  15. $test[] = gmp_init("2322");
  16. $test[] = gmp_init("2322", 8);
  17. /* Decimal */
  18. $test[] = gmp_init("1234");
  19. $test[] = gmp_init("1234", 10);
  20. /* Hexidecimal */
  21. $test[] = gmp_init("0x4d2");
  22. $test[] = gmp_init("0x4d2", 16);
  23. $test[] = gmp_init("4d2");
  24. $test[] = gmp_init("4d2", 16);
  25. for ($i = 0; $i < count($test); $i++) {
  26. printf("%s\n", gmp_strval($test[$i]));
  27. }
  28. ?>
  29. --EXPECTF--
  30. Warning: gmp_init(): Unable to convert variable to GMP - string is not an integer in %s on line %d
  31. 1234
  32. 1234
  33. 10011010010
  34. 1234
  35. 1234
  36. 1234
  37. 2322
  38. 1234
  39. 1234
  40. 1234
  41. 1234
  42. 1234
  43. 0
  44. 1234