3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertFloat($float) { $float = (string)$float; $expPos = strpos($float, 'E'); if ($expPos === false) { return $float; } $beforeDot = '0'; // Well, fuck you my English. $afterDot = '0'; // ^^ $numberWithoutPrecision = substr($float, 0, $expPos); $exp = (int)substr($float, $expPos + 1, strlen($float)); if ($exp === 0) { return '1'; } $dotPos = strpos($numberWithoutPrecision, '.'); if ($dotPos === false) { $beforeDot = $numberWithoutPrecision; } else { $beforeDot = substr($numberWithoutPrecision, 0, $dotPos); $afterDot = substr($numberWithoutPrecision, $dotPos + 1, strlen($numberWithoutPrecision)); } if ($exp < 0) { } else { $len = strlen($beforeDot); if ($len <= $exp) { return $beforeDot.($afterDot !== '0' ? $afterDot : '').str_repeat('0', $exp - $len).'i'; } else { return $beforeDot.substr($afterDot, 0, $exp).substr($afterDot, $exp, strlen($afterDot)); } } var_dump($beforeDot, $afterDot); } var_dump(convertFloat(1.004e+1));

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.00018.31
8.3.50.0110.00721.21
8.3.40.0040.01118.45
8.3.30.0110.00320.17
8.3.20.0040.00420.18
8.3.10.0080.00021.92
8.3.00.0040.00422.47
8.2.180.0150.00016.63
8.2.170.0110.00422.96
8.2.160.0040.01120.54
8.2.150.0040.00424.18
8.2.140.0130.00724.66
8.2.130.0080.00026.16
8.2.120.0080.00019.54
8.2.110.0040.00422.24
8.2.100.0070.00419.34
8.2.90.0090.00019.22
8.2.80.0000.00818.04
8.2.70.0040.00417.63
8.2.60.0000.00817.79
8.2.50.0060.00318.07
8.2.40.0050.00318.16
8.2.30.0040.00417.91
8.2.20.0000.00717.59
8.2.10.0050.00317.69
8.2.00.0070.00317.55
8.1.280.0080.00825.92
8.1.270.0060.00320.21
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0070.00323.87
8.1.230.0040.00719.09
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0110.00017.11
8.1.190.0040.00417.41
8.1.180.0080.00018.37
8.1.170.0040.00818.13
8.1.160.0000.00722.05
8.1.150.0000.00718.63
8.1.140.0000.00717.31
8.1.130.0000.00817.86
8.1.120.0040.00417.39
8.1.110.0060.00317.38
8.1.100.0040.00417.39
8.1.90.0000.00717.29
8.1.80.0040.00417.27
8.1.70.0050.00217.43
8.1.60.0030.00617.57
8.1.50.0000.00817.50
8.1.40.0040.00417.43
8.1.30.0030.00617.66
8.1.20.0060.00317.57
8.1.10.0000.00817.32
8.1.00.0060.00317.29
8.0.300.0000.00718.77
8.0.290.0040.00417.05
8.0.280.0070.00018.38
8.0.270.0030.00317.15
8.0.260.0000.00718.33
8.0.250.0070.00016.77
8.0.240.0030.00616.86
8.0.230.0030.00316.92
8.0.220.0050.00316.81
8.0.210.0000.00716.70
8.0.200.0000.00616.88
8.0.190.0000.00816.85
8.0.180.0080.00016.89
8.0.170.0040.00416.84
8.0.160.0030.00316.85
8.0.150.0040.00416.79
8.0.140.0060.00316.83
8.0.130.0060.00013.22
8.0.120.0000.00816.77
8.0.110.0040.00416.81
8.0.100.0040.00416.81
8.0.90.0040.00316.87
8.0.80.0000.01616.84
8.0.70.0030.00516.77
8.0.60.0000.00716.63
8.0.50.0040.00416.68
8.0.30.0130.00817.13
8.0.20.0070.01017.40
8.0.10.0000.00716.80
8.0.00.0130.00916.82
7.4.330.0050.00015.01
7.4.320.0030.00316.61
7.4.300.0060.00016.59
7.4.290.0020.00516.65
7.4.280.0030.00316.42
7.4.270.0030.00316.58
7.4.260.0000.00616.55
7.4.250.0070.00016.36
7.4.240.0060.00216.54
7.4.230.0070.00016.39
7.4.220.0100.01416.56
7.4.210.0060.01116.49
7.4.200.0000.00716.25
7.4.190.0000.00816.40
7.4.160.0100.00616.63
7.4.150.0140.00717.40
7.4.140.0080.01017.86
7.4.130.0070.01016.55
7.4.120.0120.00516.43
7.4.110.0120.00916.61
7.4.100.0140.00316.43
7.4.90.0080.01116.59
7.4.80.0140.01019.39
7.4.70.0070.01016.36
7.4.60.0070.01016.37
7.4.50.0030.00316.56
7.4.40.0000.01722.77
7.4.30.0120.00816.69
7.4.00.0140.00015.15
7.3.330.0020.00313.27
7.3.320.0060.00013.18
7.3.310.0040.00416.26
7.3.300.0030.00316.23
7.3.290.0030.01116.32
7.3.280.0070.00816.35
7.3.270.0110.00517.40
7.3.260.0120.00616.49
7.3.250.0090.00916.62
7.3.240.0080.01216.27
7.3.230.0100.00716.61
7.3.210.0100.00716.27
7.3.200.0100.00619.39
7.3.190.0120.00816.32
7.3.180.0100.00716.32
7.3.170.0100.00716.46
7.3.160.0040.01116.32
7.3.120.0030.01314.85
7.2.330.0130.00916.29
7.2.320.0090.00916.62
7.2.310.0100.00716.62
7.2.300.0130.00316.51
7.2.290.0140.00716.41
7.2.00.0030.01319.23
7.1.100.0070.00718.20
7.1.70.0050.00317.09
7.1.60.0090.00317.31
7.1.50.0070.00417.01
7.1.00.0070.05022.36
7.0.200.0070.00716.73
7.0.140.0070.07021.95
7.0.60.0000.08319.92
7.0.50.0070.07317.88
7.0.40.0030.08720.11
7.0.30.0230.04020.25
7.0.20.0230.05020.07
7.0.10.0270.04020.24
7.0.00.0070.06720.05
5.6.280.0100.06721.16
5.6.210.0100.07720.64
5.6.200.0170.07718.15
5.6.190.0100.06720.51
5.6.180.3570.04020.63
5.6.170.0330.08720.58
5.6.160.0170.07320.47
5.6.150.0100.04018.20
5.6.140.0030.06718.17
5.6.130.0070.04018.17
5.6.120.0070.04021.11
5.6.110.0170.07021.00
5.6.100.0070.03720.95
5.6.90.0130.07721.01
5.6.80.0030.04320.54
5.6.70.0170.08020.41
5.5.350.0200.07720.51
5.5.340.0000.05017.98
5.5.330.0000.04320.43
5.5.320.0230.07020.32
5.5.310.0170.04020.24
5.5.300.0100.06718.04
5.5.290.0070.06717.95
5.5.280.0000.04720.81
5.5.270.0000.04720.81
5.5.260.0270.05320.77
5.5.250.0070.08020.70
5.5.240.0170.03320.05
5.4.450.0700.07319.48
5.4.440.0930.06019.45
5.4.430.0770.06019.43
5.4.420.0900.06019.58
5.4.410.0770.05719.57
5.4.400.1400.04318.67
5.4.390.1170.05318.75
5.4.380.0200.06318.81
5.4.370.0200.04718.74
5.4.360.0130.05318.61
5.4.350.0140.04112.03
5.4.340.0130.04812.02
5.4.320.0060.03812.51
5.4.310.0070.04312.51
5.4.300.0050.03612.51
5.4.290.0010.04312.51
5.4.280.0020.03812.41
5.4.270.0070.03512.41
5.4.260.0030.04012.40
5.4.250.0000.05718.65
5.4.240.0070.06018.97
5.4.230.0270.05318.80
5.4.220.0070.05319.00
5.4.210.0070.05018.96
5.4.200.0170.04719.00
5.4.190.0100.05019.01
5.4.180.0030.05318.80
5.4.170.0130.05018.94
5.4.160.0070.05318.73
5.4.150.0070.05318.64
5.4.140.0100.04716.33
5.4.130.0070.05016.26
5.4.120.0170.04316.29
5.4.110.0170.06716.40
5.4.100.0170.04316.50
5.4.90.0100.05016.57
5.4.80.0130.04316.34
5.4.70.0070.05016.36
5.4.60.0130.06716.48
5.4.50.0170.04016.48
5.4.40.0170.04716.50
5.4.30.0100.04716.38
5.4.20.0070.05016.44
5.4.10.0100.07016.32
5.4.00.0200.03715.76
5.3.290.0090.03712.80
5.3.280.0030.05314.59
5.3.270.0100.05314.62
5.3.260.0130.04714.61
5.3.250.0070.05014.69
5.3.240.0230.05014.80
5.3.230.0070.05314.68
5.3.220.0030.05714.59
5.3.210.0200.04314.59
5.3.200.0230.04014.60
5.3.190.0170.04714.41
5.3.180.0030.05314.74
5.3.170.0070.05014.75
5.3.160.0100.05014.48
5.3.150.0100.04714.56
5.3.140.0070.05014.53
5.3.130.0070.05014.39
5.3.120.0030.05714.39
5.3.110.0030.06014.76
5.3.100.0170.03714.13
5.3.90.0030.05014.19
5.3.80.0170.04014.11
5.3.70.0100.04714.09
5.3.60.0030.05014.09
5.3.50.0200.03713.97
5.3.40.0100.04713.93
5.3.30.0070.04713.91
5.3.20.0070.05013.79
5.3.10.0100.04713.74
5.3.00.0170.04713.64
5.2.170.0130.03310.99
5.2.160.0100.03311.24
5.2.150.0100.03711.15
5.2.140.0030.04311.24
5.2.130.0030.04011.10
5.2.120.0070.04011.10
5.2.110.0100.04011.10
5.2.100.0100.03711.19
5.2.90.0030.04011.13
5.2.80.0000.04711.09
5.2.70.0030.04011.28
5.2.60.0030.04011.05
5.2.50.0100.03711.00
5.2.40.0100.03711.20
5.2.30.0170.03010.98
5.2.20.0170.04310.94
5.2.10.0030.04011.02
5.2.00.0170.04310.71
5.1.60.0100.04010.00
5.1.50.0030.0339.95
5.1.40.0070.0379.95
5.1.30.0100.03310.41
5.1.20.0030.03710.41
5.1.10.0100.04710.17
5.1.00.0130.02710.05
5.0.50.0070.0278.65
5.0.40.0030.0278.34
5.0.30.0000.0438.22
5.0.20.0030.0278.25
5.0.10.0000.0308.29
5.0.00.0100.0338.21
4.4.90.0030.0278.21
4.4.80.0000.0238.21
4.4.70.0000.0238.21
4.4.60.0070.0208.21
4.4.50.0030.0238.21
4.4.40.0070.0308.21
4.4.30.0070.0178.21
4.4.20.0070.0178.21
4.4.10.0070.0178.21
4.4.00.0070.0308.21
4.3.110.0070.0178.21
4.3.100.0070.0178.21
4.3.90.0070.0178.21
4.3.80.0030.0338.21
4.3.70.0030.0308.21
4.3.60.0000.0238.21
4.3.50.0030.0278.21
4.3.40.0000.0338.21
4.3.30.0000.0238.21
4.3.20.0070.0278.21
4.3.10.0000.0238.21
4.3.00.0130.0236.77

preferences:
45.51 ms | 401 KiB | 5 Q