php-src/Zend/tests/int_conversion_exponents.phpt
George Peter Banyard b2248789ed Implement 'Saner Numeric Strings' RFC:
RFC: https://wiki.php.net/rfc/saner-numeric-strings

This removes the -1 allow_error mode from is_numeric_string functions and replaces it by
a trailing boolean out argument to preserve BC in a couple of places.

Most of the changes can be resumed to "numeric" strings which emitted a E_NOTICE now emit
a E_WARNING and "numeric" strings which emitted a E_WARNING now throw a TypeError.

This mostly affects:
 - String offsets
 - Arithmetic operations
 - Bitwise operations

Closes GH-5762
2020-07-29 02:51:09 +01:00

53 lines
1.1 KiB
PHP

--TEST--
Integer conversion from scientific notation
--FILE--
<?php
var_dump((int)"1.2345e9");
var_dump((int)"-1.2345e9");
var_dump(intval("1.2345e9"));
var_dump(intval("-1.2345e9"));
var_dump("1.2345e9" % PHP_INT_MAX);
var_dump("-1.2345e9" % PHP_INT_MIN);
var_dump("1.2345e9" | 0);
var_dump("-1.2345e9" | 0);
echo PHP_EOL;
var_dump((int)" 1.2345e9 abc");
var_dump((int)" -1.2345e9 abc");
var_dump(intval(" 1.2345e9 abc"));
var_dump(intval(" -1.2345e9 abc"));
var_dump(" 1.2345e9 abc" % PHP_INT_MAX);
var_dump(" -1.2345e9 abc" % PHP_INT_MIN);
var_dump(" 1.2345e9 abc" | 0);
var_dump(" -1.2345e9 abc" | 0);
?>
--EXPECTF--
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)
Warning: A non-numeric value encountered in %s on line %d
int(1234500000)
Warning: A non-numeric value encountered in %s on line %d
int(-1234500000)
Warning: A non-numeric value encountered in %s on line %d
int(1234500000)
Warning: A non-numeric value encountered in %s on line %d
int(-1234500000)