3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(encode_float(1.1234567890123456, 13)); function encodeFloat($float, $precision) { $precision = max(1, (int) $precision); $log = (int) floor(log(abs($float), 10)); if (abs($float) < 9007199254740992.0 && $log > -5 && abs($log) < $precision) { return $this->formatFloat($float, $precision - $log - 1); } // Deal with overflow that results from rounding $log += (int) (round(abs($float) / pow(10, $log), $precision - 1) / 10); $string = $this->formatFloat($float / pow(10, $log), $precision - 1); return sprintf('%sE%+d', $string, $log); } function formatFloat($float, $digits) { $digits = max((int) $digits, 1); $string = rtrim(number_format($float, $digits, '.', ''), '0'); return substr($string, -1) === '.' ? $string . '0' : $string; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0140.00718.18
8.3.50.0110.00721.09
8.3.40.0070.01118.75
8.3.30.0040.01118.80
8.3.20.0040.00420.38
8.3.10.0000.00821.90
8.3.00.0000.00720.33
8.2.180.0160.00318.16
8.2.170.0110.01122.96
8.2.160.0030.01020.39
8.2.150.0000.00924.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0000.00917.50
8.2.110.0070.00421.04
8.2.100.0080.00417.78
8.2.90.0050.00319.05
8.2.80.0030.00517.97
8.2.70.0000.00817.63
8.2.60.0040.00417.80
8.2.50.0030.00518.10
8.2.40.0070.00319.53
8.2.30.0040.00420.72
8.2.20.0000.00817.70
8.2.10.0040.00418.10
8.2.00.0000.00717.90
8.1.280.0070.01025.92
8.1.270.0030.01023.91
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0040.00422.62
8.1.230.0040.00717.70
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0060.00317.00
8.1.190.0040.00417.11
8.1.180.0050.00318.10
8.1.170.0030.00618.55
8.1.160.0040.00421.98
8.1.150.0000.00818.79
8.1.140.0080.00017.27
8.1.130.0050.00317.54
8.1.120.0000.00817.37
8.1.110.0080.00017.35
8.1.100.0070.00017.25
8.1.90.0000.00817.25
8.1.80.0050.00217.30
8.1.70.0070.00017.38
8.1.60.0000.00817.39
8.1.50.0040.00417.49
8.1.40.0050.00317.46
8.1.30.0030.00617.59
8.1.20.0060.00317.52
8.1.10.0080.00017.57
8.1.00.0000.00817.52
8.0.300.0030.00518.77
8.0.290.0040.00416.75
8.0.280.0040.00418.48
8.0.270.0000.00717.14
8.0.260.0060.00017.15
8.0.250.0070.00016.85
8.0.240.0030.00316.88
8.0.230.0070.00017.05
8.0.220.0030.00316.91
8.0.210.0080.00016.96
8.0.200.0070.00016.92
8.0.190.0000.00716.98
8.0.180.0030.00616.96
8.0.170.0040.00416.94
8.0.160.0000.00716.89
8.0.150.0000.00716.76
8.0.140.0040.00416.73
8.0.130.0000.00613.43
8.0.120.0000.00716.76
8.0.110.0050.00216.76
8.0.100.0040.00417.03
8.0.90.0000.00816.93
8.0.80.0060.01216.97
8.0.70.0000.00816.96
8.0.60.0050.00216.82
8.0.50.0040.00416.94
8.0.30.0030.01517.07
8.0.20.0130.00917.40
8.0.10.0040.00416.86
8.0.00.0040.01216.80
7.4.330.0000.00515.08
7.4.320.0030.00316.41
7.4.300.0000.00616.45
7.4.290.0070.00016.43
7.4.280.0080.00016.50
7.4.270.0000.00616.50
7.4.260.0050.00316.55
7.4.250.0060.00316.50
7.4.240.0020.00516.57
7.4.230.0030.00316.57
7.4.220.0070.01116.53
7.4.210.0080.00716.48
7.4.200.0000.00716.66
7.4.160.0100.00716.59
7.4.150.0110.00617.40
7.4.140.0110.01117.86
7.4.130.0120.00816.50
7.4.120.0100.00916.55
7.4.110.0040.01416.74
7.4.100.0090.01516.42
7.4.90.0070.01016.49
7.4.80.0060.01319.39
7.4.70.0110.00716.59
7.4.60.0100.00716.63
7.4.50.0040.00416.30
7.4.40.0150.01316.50
7.4.30.0090.01416.32
7.4.00.0030.01415.09
7.3.330.0050.00013.18
7.3.320.0000.00513.34
7.3.310.0050.00216.13
7.3.300.0000.00716.39
7.3.290.0090.01016.34
7.3.280.0050.01116.31
7.3.270.0060.01217.40
7.3.260.0060.01016.51
7.3.250.0110.00616.40
7.3.240.0100.01116.21
7.3.230.0120.00616.46
7.3.210.0000.01716.37
7.3.200.0030.01316.39
7.3.190.0090.00616.39
7.3.180.0040.01116.46
7.3.170.0140.00316.49
7.3.160.0120.00616.40
7.2.330.0100.00716.67
7.2.320.0130.00716.36
7.2.310.0000.01816.53
7.2.300.0080.00816.28
7.2.290.0070.01116.63
7.2.60.0090.00616.44
7.2.00.0030.00918.99
7.1.200.0030.01015.69
7.1.100.0070.00417.70
7.1.70.0030.00616.96
7.1.60.0070.01819.11
7.1.50.0180.00716.95
7.1.00.0100.07022.40
7.0.200.0110.00416.54
7.0.60.0130.07019.96
7.0.50.0100.08317.82
7.0.40.0070.06320.23
7.0.30.0330.07320.11
7.0.20.0330.04720.19
7.0.10.0030.05020.24
7.0.00.0100.07320.06
5.6.280.0030.05720.91
5.6.210.0130.05320.63
5.6.200.0030.08318.20
5.6.190.0100.08320.61
5.6.180.0200.06020.67
5.6.170.0270.03320.71
5.6.160.0030.05320.50
5.6.150.0170.06018.12
5.6.140.0070.07018.12
5.6.130.0170.07318.17
5.6.120.0130.05020.89
5.6.110.0070.08321.14
5.6.100.0070.08021.10
5.6.90.0030.08721.05
5.6.80.0070.08320.43
5.5.350.0000.03320.48
5.5.340.0170.04018.02
5.5.330.0100.08720.13
5.5.320.4000.04020.30
5.5.310.0170.04020.31
5.5.300.0030.08018.00
5.5.290.0030.07018.00
5.5.280.0100.08020.66
5.5.270.0130.06720.77
5.5.260.0030.05720.88
5.5.250.0070.04320.56
5.5.240.0230.03720.27
5.4.450.1000.04319.52
5.4.440.0800.06719.43
5.4.430.0770.05719.42
5.4.420.0870.05019.55
5.4.410.0830.05019.03
5.4.400.0870.05019.12
5.4.390.0770.05718.86
5.4.380.0930.04019.06
5.4.370.0830.05018.84
5.4.360.0830.05319.23
5.4.350.0800.06019.11
5.4.340.0800.06019.19
5.4.320.0870.05719.06
5.4.310.0830.05719.30
5.4.300.0730.05719.10
5.4.290.0930.07019.10
5.4.280.0870.08019.05
5.4.270.0930.04319.06
5.4.260.0630.05718.86
5.4.250.0830.05019.22
5.4.240.0600.06719.05
5.4.230.1000.04719.00
5.4.220.0670.05719.05
5.4.210.0630.05718.93
5.4.200.0730.05319.10
5.4.190.0800.04719.21
5.4.180.0870.05019.17
5.4.170.0430.07318.86
5.4.160.0700.06019.05
5.4.150.0700.05319.24
5.4.140.1030.05716.53
5.4.130.0700.05016.39
5.4.120.0900.04716.37
5.4.110.0770.05316.63
5.4.100.0800.05716.33
5.4.90.0730.05316.30
5.4.80.0800.05016.56
5.4.70.0270.06316.49
5.4.60.0030.07716.55
5.4.50.0000.04716.40
5.4.40.0230.03716.43
5.4.30.0170.03716.53
5.4.20.0270.04316.30

preferences:
59.06 ms | 401 KiB | 5 Q