3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = gmp_pow("10", 100); $b = gmp_pow("10", 303); $c = gmp_pow("10", 600); echo "10^100 * 10^600 = ".dumbFormatScientific(gmp_mul($a, $c))." Aka.: \n"; echo gmp_mul($a, $c)."\n"; echo "10^100 * 10^303 = ".dumbFormatScientific(gmp_mul($a, $b))." Aka.: \n"; echo gmp_mul($a, $b)."\n"; function dumbFormatScientific(GMP $input) { $string = gmp_strval($input); $str_arr = str_split($string); $char_cnt = 0; foreach($str_arr as $char) { if($char == 0) { $char_cnt++; } } return "10^".$char_cnt; } ?>
Output for 5.6.0 - 5.6.20, 5.6.28, 7.0.0 - 7.0.5, 7.0.14 - 7.1.0
10^100 * 10^600 = 10^700 Aka.: 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 10^100 * 10^303 = 10^403 Aka.: 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Output for 7.0.6 - 7.0.10
Fatal error: Uncaught Error: Call to undefined function gmp_pow() in /in/3LuWY:3 Stack trace: #0 {main} thrown in /in/3LuWY on line 3
Process exited with code 255.
Output for hhvm-3.12.0
10^100 * 10^600 = 10^700 Aka.: Fatal error: Uncaught Error: Object of class GMP could not be converted to string in /in/3LuWY:8 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
10^100 * 10^600 = 10^700 Aka.: Catchable fatal error: Object of class GMP could not be converted to string in /in/3LuWY on line 8
Process exited with code 255.
Output for 5.0.0 - 5.3.29, 5.5.35 - 5.5.38, 5.6.21 - 5.6.25
Fatal error: Call to undefined function gmp_pow() in /in/3LuWY on line 3
Process exited with code 255.
Output for 5.4.0 - 5.5.34
Catchable fatal error: Argument 1 passed to dumbFormatScientific() must be an instance of GMP, resource given, called in /in/3LuWY on line 7 and defined in /in/3LuWY on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/3LuWY on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/3LuWY on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/3LuWY on line 12
Process exited with code 255.