3v4l.org

run code in 500+ PHP versions simultaneously
<?php $x = 1e-15; // naive: catastrophic cancellation $native = exp($x) - 1; echo $native; // 1.1102230246252E-15, WRONG // expm1: computed without cancellation $precise = expm1($x); echo $precise; // 1.00000000000000005E-15, CORRECT // same problem in reverse $y = 1e-15; // naive echo log(1 + $y); // 1.1102230246252E-15, WRONG echo log1p($y); // 1.00000000000000005E-15, CORRECT // real-world use: compound interest on tiny rates. $rate = 0.00001; // 0.001% daily rate $days = 365; // naive continuous compounding $wrong = exp($rate * $days) - 1; // precise $right = expm1($rate * $days);
Output for git.master_jit, rfc.property-hooks, git.master
1.1102230246252E-151.0E-151.1102230246252E-151.0E-15

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
58 ms | 2701 KiB | 4 Q