3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo whole_fraction(23.54); function whole_fraction($decimal){ $big_fraction = float2rat($decimal); $num_array = explode('/', $big_fraction); echo $big_fraction; $numerator = $num_array[0]; $denominator = $num_array[1]; echo "\n"; echo $numerator; echo "\n"; echo $denominator; $whole_number = floor( $numerator / $denominator ); $numerator = $numerator % $denominator; $fraction = $whole_number . ' ' . $numerator . '/' . $denominator; } function float2rat($n, $tolerance = 1.e-6) { $h1=1; $h2=0; $k1=0; $k2=1; $b = 1/$n; do { $b = 1/$b; $a = floor($b); $aux = $h1; $h1 = $a*$h1+$h2; $h2 = $aux; $aux = $k1; $k1 = $a*$k1+$k2; $k2 = $aux; $b = $b-$a; } while (abs($n-$h1/$k1) > $n*$tolerance); return "$h1/$k1"; }

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.70.0140.00416.50
8.3.60.0040.01118.18
8.3.50.0100.01221.28
8.3.40.0140.00418.64
8.3.30.0070.00719.09
8.3.20.0040.00420.33
8.3.10.0040.00423.78
8.3.00.0050.00319.25
8.2.180.0100.00716.75
8.2.170.0140.00022.96
8.2.160.0070.00720.38
8.2.150.0000.00724.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0040.00421.10
8.2.110.0060.00321.16
8.2.100.0070.00417.84
8.2.90.0030.00518.03
8.2.80.0040.00417.97
8.2.70.0040.00717.75
8.2.60.0000.00918.16
8.2.50.0090.00018.07
8.2.40.0050.00318.47
8.2.30.0070.00018.21
8.2.20.0000.00717.75
8.2.10.0040.00418.08
8.2.00.0080.00017.88
8.1.280.0140.00725.92
8.1.270.0060.00322.07
8.1.260.0040.00426.35
8.1.250.0020.00528.09
8.1.240.0070.01022.71
8.1.230.0080.00320.97
8.1.220.0030.00617.79
8.1.210.0110.00018.91
8.1.200.0060.00317.23
8.1.190.0000.00817.35
8.1.180.0030.00518.10
8.1.170.0000.00820.33
8.1.160.0000.00722.13
8.1.150.0040.00318.88
8.1.140.0030.00517.59
8.1.130.0000.00717.82
8.1.120.0000.00817.51
8.1.110.0000.00717.44
8.1.100.0020.00517.54
8.1.90.0000.00717.59
8.1.80.0080.00017.49
8.1.70.0050.00317.52
8.1.60.0000.01117.54
8.1.50.0000.00817.57
8.1.40.0040.00417.57
8.1.30.0000.00817.66
8.1.20.0090.00017.77
8.1.10.0060.00317.51
8.1.00.0050.00217.60
8.0.300.0030.00520.00
8.0.290.0000.00716.88
8.0.280.0030.00318.43
8.0.270.0080.00017.25
8.0.260.0000.00717.21
8.0.250.0030.00317.07
8.0.240.0060.00317.08
8.0.230.0000.00716.89
8.0.220.0030.00316.97
8.0.210.0070.00016.86
8.0.200.0030.00316.96
8.0.190.0000.01017.04
8.0.180.0050.00216.88
8.0.170.0040.00416.98
8.0.160.0000.00817.00
8.0.150.0080.00016.96
8.0.140.0000.00716.81
8.0.130.0030.00313.42
8.0.120.0000.00816.84
8.0.110.0000.00816.81
8.0.100.0040.00416.85
8.0.90.0030.00316.86
8.0.80.0130.00716.95
8.0.70.0050.00317.04
8.0.60.0030.00317.02
8.0.50.0040.00416.76
8.0.30.0110.01117.23
8.0.20.0100.00917.40
8.0.10.0040.00417.14
8.0.00.0100.01116.85
7.4.330.0050.00015.22
7.4.320.0030.00316.73
7.4.300.0040.00416.54
7.4.290.0090.00016.57
7.4.280.0030.00516.67
7.4.270.0000.00716.65
7.4.260.0080.00016.71
7.4.250.0000.00716.47
7.4.240.0040.00416.56
7.4.230.0000.00616.66
7.4.220.0130.00616.62
7.4.210.0030.01216.77
7.4.200.0000.00716.51
7.4.160.0080.00816.64
7.4.150.0070.01117.40
7.4.140.0140.00817.86
7.4.130.0100.01016.58
7.4.120.0050.01216.52
7.4.110.0140.00716.61
7.4.100.0060.00916.77
7.4.90.0150.00916.43
7.4.80.0100.00719.39
7.4.70.0080.00816.66
7.4.60.0100.01016.43
7.4.50.0030.00616.69
7.4.40.0160.00416.45
7.4.30.0030.01316.71
7.4.10.0040.01414.79
7.4.00.0070.01014.90
7.3.330.0000.00513.26
7.3.320.0020.00213.31
7.3.310.0030.00316.25
7.3.300.0040.00416.31
7.3.290.0050.00916.46
7.3.280.0080.00816.45
7.3.270.0080.01117.40
7.3.260.0140.00316.50
7.3.250.0150.00616.53
7.3.240.0100.01016.51
7.3.230.0080.00816.48
7.3.210.0190.00016.53
7.3.200.0120.00419.39
7.3.190.0030.01316.61
7.3.180.0150.00616.43
7.3.170.0080.00816.37
7.3.160.0070.01016.67
7.3.130.0060.00914.52
7.3.120.0120.00514.78
7.3.110.0110.00614.73
7.3.100.0030.01414.88
7.3.90.0110.00414.83
7.3.80.0030.01114.88
7.3.70.0070.00514.76
7.3.60.0010.01214.76
7.3.50.0040.01114.71
7.3.40.0050.00714.90
7.3.30.0080.00714.88
7.3.20.0050.00916.78
7.3.10.0080.00616.47
7.3.00.0090.00416.82
7.2.330.0120.00616.93
7.2.320.0130.01016.77
7.2.310.0030.01416.84
7.2.300.0030.01316.71
7.2.290.0150.00916.68
7.2.260.0070.01315.22
7.2.250.0080.00815.17
7.2.240.0110.00514.95
7.2.230.0070.00915.18
7.2.220.0100.00715.05
7.2.210.0020.00915.02
7.2.200.0020.00915.08
7.2.190.0040.00715.02
7.2.180.0050.01015.04
7.2.170.0080.00715.01
7.2.160.0030.01014.84
7.2.150.0090.00917.01
7.2.140.0110.00717.04
7.2.130.0030.01016.92
7.2.120.0030.00616.84
7.2.110.0090.00617.08
7.2.100.0090.00616.86
7.2.90.0120.00617.06
7.2.80.0110.00617.02
7.2.70.0090.01017.08
7.2.60.0100.00716.98
7.2.50.0070.00316.87
7.2.40.0080.00317.11
7.2.30.0060.00617.10
7.2.20.0070.01016.66
7.2.10.0060.01316.66
7.2.00.0040.01118.20
7.1.330.0030.01015.96
7.1.320.0030.00815.86
7.1.310.0080.00615.80
7.1.300.0060.00615.78
7.1.290.0030.01115.84
7.1.280.0090.00615.91
7.1.270.0050.00615.60
7.1.260.0020.00915.90
7.1.250.0030.00715.58
7.1.240.0030.01315.97
7.1.230.0030.01315.68
7.1.220.0070.00715.67
7.1.210.0040.00415.97
7.1.200.0080.00815.68
7.1.190.0030.00716.01
7.1.180.0060.00915.81
7.1.170.0080.00415.64
7.1.160.0050.00515.89
7.1.150.0040.00816.00
7.1.140.0060.01215.49
7.1.130.0040.00715.81
7.1.120.0000.01215.68
7.1.110.0000.01515.92
7.1.100.0030.01016.87
7.1.90.0030.01015.91
7.1.80.0040.01115.86
7.1.70.0070.00816.57
7.1.60.0070.01117.61
7.1.50.0090.00516.39
7.1.40.0030.00615.59
7.1.30.0100.00315.95
7.1.20.0080.00815.86
7.1.10.0040.01515.80
7.1.00.0020.04319.04
7.0.330.0040.01115.49
7.0.320.0030.01015.32
7.0.310.0070.01015.24
7.0.300.0000.01515.43
7.0.290.0030.01415.54
7.0.280.0000.01415.50
7.0.270.0060.00615.39
7.0.260.0100.00315.52
7.0.250.0070.00715.51
7.0.240.0030.00715.43
7.0.230.0070.01015.49
7.0.220.0040.00815.61
7.0.210.0090.00615.41
7.0.200.0030.00816.08
7.0.190.0070.00715.65
7.0.180.0040.00715.50
7.0.170.0070.00715.57
7.0.160.0090.00315.45
7.0.150.0030.00615.61
7.0.140.0040.03818.77
7.0.130.0030.00915.64
7.0.120.0030.01015.53
7.0.110.0100.00315.60
7.0.100.0030.00615.43
7.0.90.0040.01115.58
7.0.80.0100.00315.65
7.0.70.0090.00615.65
7.0.60.0070.04317.54
7.0.50.0070.03016.63
7.0.40.0070.04516.80
7.0.30.0270.03216.69
7.0.20.0210.03516.86
7.0.10.0050.04416.77
7.0.00.0100.03716.71
5.6.400.0040.00414.33
5.6.390.0100.00714.30
5.6.380.0110.00414.54
5.6.370.0070.00714.73
5.6.360.0090.00614.41
5.6.350.0060.00314.64
5.6.340.0060.00914.21
5.6.330.0040.01114.08
5.6.320.0040.00414.27
5.6.310.0110.00414.77
5.6.300.0040.01114.74
5.6.290.0030.00614.34
5.6.280.0080.03517.82
5.6.270.0000.00814.60
5.6.260.0060.00614.39
5.6.250.0030.01214.25
5.6.240.0070.00714.40
5.6.230.0060.00914.44
5.6.220.0030.01214.18
5.6.210.0030.04917.48
5.6.200.0050.02716.21
5.6.190.0050.03717.63
5.6.180.0080.04317.51
5.6.170.0190.04917.35
5.6.160.0050.04917.56
5.6.150.0100.02316.26
5.6.140.0080.03816.44
5.6.130.0070.02816.30
5.6.120.0100.04217.89
5.6.110.0090.04117.67
5.6.100.0080.03017.93
5.6.90.0110.03617.76
5.6.80.0040.02417.27
5.6.70.1600.01717.31
5.6.60.0030.01014.35
5.6.50.0030.01014.48
5.6.40.0030.01014.26
5.6.30.0030.00714.30
5.6.20.0030.01314.17
5.6.10.0090.00314.46
5.6.00.0090.00014.31
5.5.380.0080.00414.32
5.5.370.0030.00714.32
5.5.360.0100.00614.35
5.5.350.0160.02517.29
5.5.340.0060.02216.08
5.5.330.0070.04017.33
5.5.320.0160.01917.27
5.5.310.0140.04717.27
5.5.300.0050.04416.26
5.5.290.0070.03716.33
5.5.280.0120.04117.72
5.5.270.0030.03217.45
5.5.260.0050.03217.61
5.5.250.0050.02817.54
5.5.240.2030.02517.10
5.5.230.0040.01214.39
5.5.220.0000.01514.43
5.5.210.0040.01114.36
5.5.200.0070.00714.46
5.5.190.0120.00314.40
5.5.180.0030.01214.52
5.5.170.0030.01214.21
5.5.160.0030.01014.45
5.5.150.0090.00614.53
5.5.140.0000.01414.11
5.5.130.0040.01114.15
5.5.120.0060.00614.14
5.5.110.0030.00914.20
5.5.100.0040.01114.13
5.5.90.0120.00314.27
5.5.80.0070.01014.52
5.5.70.0000.01114.30
5.5.60.0080.00314.12
5.5.50.0000.01214.10
5.5.40.0120.00314.07
5.5.30.0040.01114.13
5.5.20.0060.00914.34
5.5.10.0080.00414.10
5.5.00.0100.00713.88
5.4.450.0380.03416.21
5.4.440.0380.03516.15
5.4.430.0070.03216.07
5.4.420.0400.02916.26
5.4.410.0450.02516.14
5.4.400.0500.02716.03
5.4.390.0470.02515.98
5.4.380.0080.03115.97
5.4.370.0340.02915.83
5.4.360.0140.02515.94
5.4.350.0380.03016.05
5.4.340.0070.01912.42
5.4.330.0080.00312.82
5.4.320.0040.02012.67
5.4.310.0050.02212.67
5.4.300.0040.02412.67
5.4.290.0030.02612.66
5.4.280.0050.02012.62
5.4.270.0040.02212.61
5.4.260.0040.02212.61
5.4.250.0080.02012.61
5.4.240.0060.02212.62
5.4.230.0060.01912.61
5.4.220.0040.02012.61
5.4.210.0040.02112.61
5.4.200.0070.02112.61
5.4.190.0030.02312.61
5.4.180.0020.02312.61
5.4.170.0040.02712.61
5.4.160.0070.02212.61
5.4.150.0050.02212.61
5.4.140.0060.02012.45
5.4.130.0070.01812.44
5.4.120.0060.01912.42
5.4.110.0060.02112.42
5.4.100.0040.02312.42
5.4.90.0040.02612.42
5.4.80.0060.02412.42
5.4.70.0070.01812.42
5.4.60.0070.01912.42
5.4.50.0050.01812.42
5.4.40.0050.02212.41
5.4.30.0070.01812.41
5.4.20.0040.02112.41
5.4.10.0030.02012.41
5.4.00.0080.01812.16
5.3.290.0070.03812.80
5.3.280.0080.03512.71
5.3.270.0090.03512.73
5.3.260.0080.03612.72
5.3.250.0050.03712.72
5.3.240.0050.03712.72
5.3.230.0080.03412.70
5.3.220.0090.03512.68
5.3.210.0080.05012.68
5.3.200.0050.03612.68
5.3.190.0040.03912.68
5.3.180.0100.03812.67
5.3.170.0070.03512.67
5.3.160.0070.03412.68
5.3.150.0030.03812.67
5.3.140.0040.03712.66
5.3.130.0090.04312.66
5.3.120.0040.04512.66
5.3.110.0060.03812.66
5.3.100.0050.03712.13
5.3.90.0040.03712.11
5.3.80.0080.03312.10
5.3.70.0080.03412.10
5.3.60.0030.03912.09
5.3.50.0040.04812.03
5.3.40.0070.03512.03
5.3.30.0060.04711.99
5.3.20.0090.03211.77
5.3.10.0050.03511.74
5.3.00.0050.03511.72
5.2.170.0030.0319.22
5.2.160.0030.0319.23
5.2.150.0100.0259.22
5.2.140.0050.0289.22
5.2.130.0000.0339.18
5.2.120.0040.0289.18
5.2.110.0030.0299.19
5.2.100.0030.0309.19
5.2.90.0060.0269.19
5.2.80.0060.0299.18
5.2.70.0040.0319.18
5.2.60.0040.0309.14
5.2.50.0110.0309.11
5.2.40.0040.0299.08
5.2.30.0070.0299.06
5.2.20.0020.0319.04
5.2.10.0040.0288.96
5.2.00.0050.0288.83
5.1.60.0040.0248.11
5.1.50.0040.0288.11
5.1.40.0060.0278.09
5.1.30.0080.0268.44
5.1.20.0030.0318.46
5.1.10.0030.0268.19
5.1.00.0040.0308.19
5.0.50.0030.0256.68
5.0.40.0050.0236.54
5.0.30.0060.0306.36
5.0.20.0050.0186.33
5.0.10.0060.0236.32
5.0.00.0060.0366.30
4.4.90.0020.0154.78
4.4.80.0000.0174.75
4.4.70.0030.0144.75
4.4.60.0010.0174.75
4.4.50.0040.0134.77
4.4.40.0020.0254.71
4.4.30.0040.0134.75
4.4.20.0020.0154.84
4.4.10.0000.0184.85
4.4.00.0040.0234.76
4.3.110.0050.0124.67
4.3.100.0020.0154.67
4.3.90.0010.0164.63
4.3.80.0060.0214.61
4.3.70.0020.0154.63
4.3.60.0050.0124.63
4.3.50.0020.0164.63
4.3.40.0050.0224.55
4.3.30.0010.0163.36
4.3.20.0020.0163.35
4.3.10.0010.0163.30
4.3.00.0170.0206.80

preferences:
45.05 ms | 401 KiB | 5 Q