3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s1 = bchexdec('44e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e'); $s2 = bchexdec('9a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab'); echo bcdechex(invmod($s1, -$s2)); function invmod($a,$b) { $n=$b; $x=0; $lx=1; $y=1; $ly=0; while ($b) { $t=$b; $q=bcdiv($a,$b,0); $b=bcmod($a,$b); $a=$t; $t=$x; $x=bcsub($lx,bcmod(bcmul($q,$x),$n)); $lx=$t; $t=$y; $y=bcsub($ly,bcmod(bcmul($q,$y),$n)); $ly=$t; } if (bccomp($lx,0) == -1) $lx=bcadd($lx,$n); return $lx; } function bchexdec($hex) { if(strlen($hex) == 1) { return hexdec($hex); } else { $remain = substr($hex, 0, -1); $last = substr($hex, -1); return bcadd(bcmul(16, bchexdec($remain)), hexdec($last)); } } function bcdechex($dec) { $last = bcmod($dec, 16); $remain = bcdiv(bcsub($dec, $last), 16); if($remain == 0) { return dechex($last); } else { return bcdechex($remain).dechex($last); } }
Output for 8.0.2 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.24, 8.3.0 - 8.3.12
Fatal error: Uncaught ValueError: bcdiv(): Argument #2 ($num2) is not well-formed in /in/qqi85:12 Stack trace: #0 /in/qqi85(12): bcdiv('311565754784503...', '-6.982422558024...', 0) #1 /in/qqi85(5): invmod('311565754784503...', -6.982422558024E+76) #2 {main} thrown in /in/qqi85 on line 12
Process exited with code 255.
Output for 7.0.5, 7.3.32 - 7.3.33, 7.4.33, 8.0.13
Fatal error: Uncaught Error: Call to undefined function bcadd() in /in/qqi85:29 Stack trace: #0 /in/qqi85(2): bchexdec('44e1ff2dfd8102c...') #1 {main} thrown in /in/qqi85 on line 29
Process exited with code 255.
Output for 8.0.0 - 8.0.1
Warning: bcdiv(): bcmath function argument is not well-formed in /in/qqi85 on line 12 Fatal error: Uncaught DivisionByZeroError: Division by zero in /in/qqi85:12 Stack trace: #0 /in/qqi85(12): bcdiv('311565754784503...', '-6.982422558024...', 0) #1 /in/qqi85(5): invmod('311565754784503...', -6.982422558024E+76) #2 {main} thrown in /in/qqi85 on line 12
Process exited with code 255.
Output for 7.4.0 - 7.4.32
Warning: bcdiv(): bcmath function argument is not well-formed in /in/qqi85 on line 12 Warning: bcdiv(): Division by zero in /in/qqi85 on line 12 Warning: bcmod(): bcmath function argument is not well-formed in /in/qqi85 on line 13 Warning: bcmod(): Division by zero in /in/qqi85 on line 13 Warning: bcmod(): bcmath function argument is not well-formed in /in/qqi85 on line 15 Warning: bcmod(): Division by zero in /in/qqi85 on line 15 Warning: bcmod(): bcmath function argument is not well-formed in /in/qqi85 on line 16 Warning: bcmod(): Division by zero in /in/qqi85 on line 16 0
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.28, 5.5.31 - 5.5.33, 5.5.35, 5.6.7 - 5.6.12, 5.6.16 - 5.6.19, 5.6.21 - 5.6.28, 7.0.0 - 7.0.4, 7.0.6 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.31
Warning: bcdiv(): Division by zero in /in/qqi85 on line 12 Warning: bcmod(): Division by zero in /in/qqi85 on line 13 Warning: bcmod(): Division by zero in /in/qqi85 on line 15 Warning: bcmod(): Division by zero in /in/qqi85 on line 16 0
Output for 5.5.29 - 5.5.30, 5.5.34, 5.6.13 - 5.6.15, 5.6.20
Fatal error: Call to undefined function bcadd() in /in/qqi85 on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: bcdiv() [http://www.php.net/function.bcdiv]: Division by zero in /in/qqi85 on line 12 Warning: bcmod() [http://www.php.net/function.bcmod]: Division by zero in /in/qqi85 on line 13 Warning: bcmod() [http://www.php.net/function.bcmod]: Division by zero in /in/qqi85 on line 15 Warning: bcmod() [http://www.php.net/function.bcmod]: Division by zero in /in/qqi85 on line 16 0

preferences:
86.39 ms | 416 KiB | 5 Q