<?php
function a($val) {
$maxValue = (int) (\PHP_INT_MAX / 1000);
$value = $val * 1000;
echo 'Value: '.\gettype($val).' '.$val.PHP_EOL;
echo 'Timer: '.\gettype($value).' '.$value.PHP_EOL;
echo 'Casted: '.((int) $value).PHP_EOL;
echo 'Overflow: '.\var_export($val > $maxValue, true).PHP_EOL;
echo 'Overflow <0: '.\var_export(((int) $value) <= 0 && $val > 0, true).PHP_EOL;
echo 'PHP Overflow: '.\var_export($value > \PHP_INT_MAX, true).PHP_EOL;
echo 'Overflow combined: '.\var_export($value > \PHP_INT_MAX || (((int) $value) <= 0 && $val > 0), true).PHP_EOL;
echo 'Supposed to fail: '.\var_export(\gettype($value) === 'double', true).PHP_EOL;
echo PHP_EOL;
}
$maxValue = (int) (\PHP_INT_MAX / 1000);
echo 'Max value: '.$maxValue.PHP_EOL;
echo 'Max PHP value: '.\PHP_INT_MAX.PHP_EOL.PHP_EOL;
a($maxValue);
a($maxValue - 1);
a($maxValue + 1);
a($maxValue + 10);
a($maxValue + 10000000);
a(\PHP_INT_MAX);
a(\PHP_INT_MAX + 1);
a(\PHP_INT_MAX + 10);
a(\PHP_INT_MAX + 100);
a(\PHP_INT_MAX + 10000000);
a(\PHP_INT_MAX * 1000);
- Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Max value: 9223372036854776
Max PHP value: 9223372036854775807
Value: integer 9223372036854776
Timer: double 9.2233720368548E+18
Casted: -9223372036854775808
Overflow: false
Overflow <0: true
PHP Overflow: false
Overflow combined: true
Supposed to fail: true
Value: integer 9223372036854775
Timer: integer 9223372036854775000
Casted: 9223372036854775000
Overflow: false
Overflow <0: false
PHP Overflow: false
Overflow combined: false
Supposed to fail: false
Value: integer 9223372036854777
Timer: double 9.2233720368548E+18
Casted: -9223372036854775808
Overflow: true
Overflow <0: true
PHP Overflow: false
Overflow combined: true
Supposed to fail: true
Value: integer 9223372036854786
Timer: double 9.2233720368548E+18
Casted: -9223372036854765568
Overflow: true
Overflow <0: true
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
Value: integer 9223372046854776
Timer: double 9.2233720468548E+18
Casted: -9223372026854774784
Overflow: true
Overflow <0: true
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
Value: integer 9223372036854775807
Timer: double 9.2233720368548E+21
Casted: 0
Overflow: true
Overflow <0: true
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
Value: double 9.2233720368548E+18
Timer: double 9.2233720368548E+21
Casted: 0
Overflow: true
Overflow <0: true
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
Value: double 9.2233720368548E+18
Timer: double 9.2233720368548E+21
Casted: 0
Overflow: true
Overflow <0: true
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
Value: double 9.2233720368548E+18
Timer: double 9.2233720368548E+21
Casted: 0
Overflow: true
Overflow <0: true
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
Value: double 9.2233720368648E+18
Timer: double 9.2233720368648E+21
Casted: 10000269312
Overflow: true
Overflow <0: false
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
Value: double 9.2233720368548E+21
Timer: double 9.2233720368548E+24
Casted: 0
Overflow: true
Overflow <0: true
PHP Overflow: true
Overflow combined: true
Supposed to fail: true
preferences:
193.67 ms | 411 KiB | 169 Q