3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(encodeFloat(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.0120.00918.53
8.3.50.0160.00621.21
8.3.40.0040.01119.09
8.3.30.0110.00418.70
8.3.20.0070.00020.41
8.3.10.0030.00622.01
8.3.00.0040.00420.63
8.2.180.0120.00918.54
8.2.170.0060.00922.96
8.2.160.0000.01420.52
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0030.00617.88
8.2.110.0070.00422.50
8.2.100.0090.00317.88
8.2.90.0080.00019.38
8.2.80.0000.01017.97
8.2.70.0040.00417.88
8.2.60.0040.00418.15
8.2.50.0050.00318.07
8.2.40.0070.00219.53
8.2.30.0030.00320.71
8.2.20.0040.00417.89
8.2.10.0040.00418.28
8.2.00.0040.00418.32
8.1.280.0140.00325.92
8.1.270.0040.01224.06
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0030.00622.73
8.1.230.0060.00617.61
8.1.220.0040.00417.89
8.1.210.0080.00018.77
8.1.200.0000.00917.50
8.1.190.0040.00417.47
8.1.180.0040.00418.10
8.1.170.0050.00518.82
8.1.160.0040.00422.21
8.1.150.0070.00019.14
8.1.140.0050.00517.59
8.1.130.0050.00317.90
8.1.120.0000.00717.60
8.1.110.0000.00717.69
8.1.100.0000.00817.71
8.1.90.0030.00617.64
8.1.80.0030.00417.64
8.1.70.0000.00717.55
8.1.60.0060.00317.80
8.1.50.0080.00017.73
8.1.40.0030.00617.72
8.1.30.0040.00417.83
8.1.20.0040.00417.88
8.1.10.0000.00917.81
8.1.00.0040.00417.76
8.0.300.0080.00018.77
8.0.290.0040.00417.00
8.0.280.0040.00418.57
8.0.270.0070.00017.33
8.0.260.0000.00618.52
8.0.250.0040.00417.21
8.0.240.0000.00717.25
8.0.230.0040.00417.09
8.0.220.0000.00817.05
8.0.210.0040.00417.16
8.0.200.0000.00717.24
8.0.190.0050.00217.29
8.0.180.0080.00017.21
8.0.170.0040.00417.22
8.0.160.0070.00017.08
8.0.150.0040.00417.10
8.0.140.0040.00417.05
8.0.130.0030.00313.62
8.0.120.0040.00417.06
8.0.110.0000.00817.13
8.0.100.0070.00017.11
8.0.90.0000.00717.21
8.0.80.0040.01217.13
8.0.70.0000.00717.07
8.0.60.0000.00717.21
8.0.50.0000.00717.23
8.0.30.0080.00917.25
8.0.20.0100.00917.40
8.0.10.0050.00317.09
8.0.00.0090.00817.00
7.4.330.0050.00015.16
7.4.320.0060.00016.77
7.4.300.0030.00316.76
7.4.290.0000.00716.71
7.4.280.0050.00316.84
7.4.270.0070.00016.81
7.4.260.0000.00716.69
7.4.250.0000.00716.84
7.4.240.0030.00516.79
7.4.230.0040.00416.81
7.4.220.0100.01016.75
7.4.210.0100.00716.91
7.4.200.0030.00316.80
7.4.160.0060.01216.76
7.4.150.0100.01317.40
7.4.140.0110.00817.86
7.4.130.0170.01316.83
7.4.120.0080.00916.78
7.4.110.0070.01016.84
7.4.100.0090.00916.73
7.4.90.0090.00916.71
7.4.80.0160.00619.39
7.4.70.0040.01216.88
7.4.60.0100.00716.65
7.4.50.0060.00316.76
7.4.40.0200.00616.76
7.4.30.0100.01016.69
7.4.00.0030.01015.29
7.3.330.0050.00013.41
7.3.320.0030.00313.55
7.3.310.0000.00716.38
7.3.300.0030.00316.45
7.3.290.0070.00616.55
7.3.280.0100.00916.53
7.3.270.0110.00717.40
7.3.260.0030.01316.69
7.3.250.0100.00916.67
7.3.240.0080.01716.44
7.3.230.0110.00816.74
7.3.210.0120.00616.64
7.3.200.0060.01316.64
7.3.190.0060.01116.76
7.3.180.0100.00616.63
7.3.170.0080.00816.71
7.3.160.0170.00016.81
7.2.330.0110.01816.88
7.2.320.0090.00916.91
7.2.310.0060.01116.79
7.2.300.0060.01016.78
7.2.290.0100.00716.67
7.2.60.0030.01016.91
7.2.00.0000.01419.84
7.1.200.0000.01215.81
7.1.100.0000.00918.54
7.1.70.0070.00017.44
7.1.60.0060.01919.11
7.1.50.0170.00717.39
7.1.00.0100.07022.64
7.0.200.0070.00317.06
7.0.60.0100.07720.29
7.0.50.0000.04318.11
7.0.40.0100.04020.52
7.0.30.0270.08320.51
7.0.20.0330.06320.35
7.0.10.0070.05720.52
7.0.00.0030.06020.45
5.6.280.0000.05321.13
5.6.210.0100.07720.86
5.6.200.0100.04318.45
5.6.190.0000.05020.78
5.6.180.0470.07720.78
5.6.170.0270.08020.75
5.6.160.0000.09020.80
5.6.150.0070.08018.46
5.6.140.0100.06318.52
5.6.130.0100.05018.43
5.6.120.0070.07021.29
5.6.110.0070.07021.37
5.6.100.0130.07321.30
5.6.90.0100.07321.25
5.6.80.0000.04720.70
5.5.350.0070.07320.74
5.5.340.0130.04318.21
5.5.330.0130.08320.82
5.5.320.0500.07020.53
5.5.310.0230.05020.64
5.5.300.0130.05718.30
5.5.290.0030.08718.20
5.5.280.0070.06021.07
5.5.270.0070.04321.05
5.5.260.0170.05321.16
5.5.250.0000.09720.97
5.5.240.0070.08020.32
5.4.450.0800.06319.66
5.4.440.0900.06019.63
5.4.430.0700.06319.39
5.4.420.0930.04719.63
5.4.410.0900.05019.21
5.4.400.0770.06019.14
5.4.390.0730.06319.00
5.4.380.0830.05319.13
5.4.370.0930.05319.35
5.4.360.0870.05319.48
5.4.350.0800.05319.33
5.4.340.0770.04719.00
5.4.320.0630.05019.41
5.4.310.0630.05019.35
5.4.300.0700.05319.30
5.4.290.0600.05719.36
5.4.280.0630.05319.16
5.4.270.0700.04719.30
5.4.260.0700.04719.07
5.4.250.0630.05319.34
5.4.240.0830.03719.40
5.4.230.0700.04719.21
5.4.220.0600.05718.92
5.4.210.0930.04319.20
5.4.200.0670.05019.32
5.4.190.0930.04018.91
5.4.180.0770.05319.47
5.4.170.0800.05319.19
5.4.160.0800.05719.05
5.4.150.0900.04719.32
5.4.140.0770.06016.48
5.4.130.0770.05716.64
5.4.120.0970.05316.43
5.4.110.0870.04716.68
5.4.100.0800.05016.80
5.4.90.0830.04716.39
5.4.80.0770.05316.68
5.4.70.0170.04016.88
5.4.60.0300.06316.59
5.4.50.0100.04316.57
5.4.40.0270.06716.74
5.4.30.0270.02716.79
5.4.20.0270.05316.82

preferences:
56.82 ms | 401 KiB | 5 Q