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 $denomenator; $whole_number = floor( $numerator / $denominator ); $numerator = $numerator % $denomenator; $fraction = $whole_number . ' ' . $numerator . '/' . $denomenator; } 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.60.0040.01418.68
8.3.50.0000.01416.63
8.3.40.0040.01118.74
8.3.30.0120.00319.22
8.3.20.0080.00020.43
8.3.10.0030.00523.79
8.3.00.0060.00319.38
8.2.180.0070.01416.75
8.2.170.0070.01422.96
8.2.160.0080.00620.52
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00021.08
8.2.110.0090.00022.12
8.2.100.0060.00617.88
8.2.90.0030.00619.22
8.2.80.0030.00517.97
8.2.70.0060.00617.75
8.2.60.0060.00318.16
8.2.50.0060.00318.07
8.2.40.0000.00819.74
8.2.30.0040.00418.08
8.2.20.0080.00017.88
8.2.10.0040.00418.07
8.2.00.0080.00017.84
8.1.280.0150.00825.92
8.1.270.0060.00322.18
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0040.00423.98
8.1.230.0040.00819.26
8.1.220.0000.00817.91
8.1.210.0050.00318.77
8.1.200.0060.00317.48
8.1.190.0000.00817.35
8.1.180.0000.00818.10
8.1.170.0040.00420.41
8.1.160.0040.00421.95
8.1.150.0080.00018.89
8.1.140.0000.00717.47
8.1.130.0080.00017.82
8.1.120.0050.00317.41
8.1.110.0000.00717.36
8.1.100.0040.00417.51
8.1.90.0000.00717.53
8.1.80.0040.00417.41
8.1.70.0030.00317.35
8.1.60.0070.00717.61
8.1.50.0000.00817.51
8.1.40.0030.00617.57
8.1.30.0000.00817.55
8.1.20.0040.00417.63
8.1.10.0000.00717.66
8.1.00.0080.00017.45
8.0.300.0000.00818.77
8.0.290.0040.00416.88
8.0.280.0030.00318.48
8.0.270.0000.00717.33
8.0.260.0030.00317.40
8.0.250.0000.00717.03
8.0.240.0070.00017.04
8.0.230.0030.00316.98
8.0.220.0000.00716.93
8.0.210.0000.00717.05
8.0.200.0030.00316.96
8.0.190.0000.00817.08
8.0.180.0040.00417.07
8.0.170.0030.00517.05
8.0.160.0040.00417.04
8.0.150.0030.00516.95
8.0.140.0000.00717.05
8.0.130.0080.00013.46
8.0.120.0080.00016.89
8.0.110.0000.00717.01
8.0.100.0040.00417.09
8.0.90.0000.00817.07
8.0.80.0000.01616.98
8.0.70.0040.00417.04
8.0.60.0000.00717.09
8.0.50.0050.00317.09
8.0.30.0110.00817.19
8.0.20.0120.01117.40
8.0.10.0000.00817.15
8.0.00.0080.01016.97
7.4.330.0000.00515.14
7.4.320.0000.00616.59
7.4.300.0060.00016.54
7.4.290.0050.00316.59
7.4.280.0040.00416.68
7.4.270.0030.00316.57
7.4.260.0030.00316.58
7.4.250.0050.00216.66
7.4.240.0020.00616.68
7.4.230.0030.00316.60
7.4.220.0060.01216.50
7.4.210.0120.00916.57
7.4.200.0030.00316.71
7.4.160.0090.00616.84
7.4.150.0210.00717.40
7.4.140.0070.01417.86
7.4.130.0110.00716.57
7.4.120.0110.00516.71
7.4.110.0130.01016.52
7.4.100.0030.01316.43
7.4.90.0070.01016.62
7.4.80.0100.00719.39
7.4.70.0070.01016.68
7.4.60.0120.00616.77
7.4.50.0040.00416.49
7.4.40.0080.00816.59
7.4.30.0100.00716.82
7.4.00.0090.00814.83
7.3.330.0050.00013.48
7.3.320.0030.00313.34
7.3.310.0040.00416.40
7.3.300.0040.00416.50
7.3.290.0080.00616.48
7.3.280.0110.00816.50
7.3.270.0090.00917.40
7.3.260.0070.01216.83
7.3.250.0120.00616.51
7.3.240.0090.01216.61
7.3.230.0120.00416.63
7.3.210.0080.00816.61
7.3.200.0090.01219.39
7.3.190.0100.00716.55
7.3.180.0080.00816.52
7.3.170.0090.00916.58
7.3.160.0210.00016.42
7.3.120.0110.00714.97
7.3.110.0060.01215.09
7.3.100.0040.01014.89
7.3.90.0060.00614.76
7.3.80.0040.01014.75
7.3.70.0060.00714.91
7.3.60.0040.01114.79
7.3.50.0050.00914.83
7.3.40.0070.00814.89
7.3.30.0040.00814.77
7.3.20.0110.00316.83
7.3.10.0090.00916.67
7.3.00.0080.00416.71
7.2.330.0040.01416.84
7.2.320.0130.00416.66
7.2.310.0030.01416.92
7.2.300.0100.01116.95
7.2.290.0140.00316.81
7.2.250.0070.01114.93
7.2.240.0070.01315.11
7.2.230.0110.00514.80
7.2.220.0060.00714.91
7.2.210.0020.00914.96
7.2.200.0010.01214.94
7.2.190.0090.00514.86
7.2.180.0070.00714.89
7.2.170.0070.00614.94
7.2.60.0190.00316.95
7.2.00.0000.01419.64
7.1.330.0080.00615.68
7.1.320.0040.00615.87
7.1.310.0040.00915.82
7.1.300.0060.00615.71
7.1.290.0060.00515.73
7.1.280.0040.00815.81
7.1.270.0050.00715.79
7.1.260.0060.00715.76
7.1.200.0000.01115.57
7.1.100.0100.00318.12
7.1.70.0000.00817.23
7.1.60.0100.01419.32
7.1.50.0090.00917.01
7.1.00.0070.07322.57
7.0.200.0070.00316.82
7.0.140.0000.07722.01
7.0.60.0130.07719.93
7.0.50.0100.06317.88
7.0.40.0130.07720.13
7.0.30.0270.06320.08
7.0.20.0270.07320.07
7.0.10.0030.06720.23
7.0.00.0200.06020.12
5.6.280.0100.06721.13
5.6.210.0100.03720.61
5.6.200.0070.08018.22
5.6.190.0030.07320.55
5.6.180.0200.07320.48
5.6.170.0230.08720.48
5.6.160.0070.06720.44
5.6.150.0100.07718.23
5.6.140.0000.05318.24
5.6.130.0070.03718.17
5.6.120.0070.07321.02
5.6.110.0170.03720.99
5.6.100.0100.08321.14
5.6.90.0070.07021.00
5.6.80.0100.07320.38
5.6.70.4230.03720.29
5.5.350.0200.04320.38
5.5.340.0070.08017.94
5.5.330.0100.08020.62
5.5.320.0230.03720.35
5.5.310.0370.06320.31
5.5.300.0070.08017.99
5.5.290.0030.04317.98
5.5.280.0070.08320.91
5.5.270.0170.05720.87
5.5.260.0000.04320.98
5.5.250.0130.07720.62
5.5.240.3400.03320.28
5.4.450.0830.05019.39
5.4.440.0700.05019.45
5.4.430.0270.05319.48
5.4.420.1000.04319.30
5.4.410.0900.06719.35
5.4.400.0070.06019.15
5.4.390.0830.05319.23
5.4.380.0800.04719.06
5.4.370.0630.04719.25
5.4.360.0800.06719.27
5.4.350.0630.05319.14
5.4.340.0060.03312.02
5.4.320.0050.03612.51
5.4.310.0050.03712.51
5.4.300.0080.03412.52
5.4.290.0010.04112.51
5.4.280.0050.03712.41
5.4.270.0090.03212.41
5.4.260.0050.03812.41
5.4.250.0090.03312.41
5.4.240.0050.03712.41
5.4.230.0070.03912.40
5.4.220.0030.03812.40
5.4.210.0100.03312.39
5.4.200.0040.04512.40
5.4.190.0070.03512.40
5.4.180.0080.03512.40
5.4.170.0050.04312.39
5.4.160.0080.04112.39
5.4.150.0070.03512.39
5.4.140.0080.04112.07
5.4.130.0070.03412.06
5.4.120.0060.03412.02
5.4.110.0070.03312.02
5.4.100.0040.03812.01
5.4.90.0060.03712.02
5.4.80.0070.03612.02
5.4.70.0070.03412.02
5.4.60.0070.03412.02
5.4.50.0060.03412.01
5.4.40.0040.03512.00
5.4.30.0060.03512.00
5.4.20.0040.03612.00
5.4.10.0050.03412.00
5.4.00.0070.03411.49
5.3.290.0080.03712.80
5.3.280.0030.04012.70
5.3.270.0080.04212.72
5.3.260.0040.04512.72
5.3.250.0090.03912.72
5.3.240.0130.03612.72
5.3.230.0090.03312.71
5.3.220.0070.04012.68
5.3.210.0110.04312.68
5.3.200.0060.03712.68
5.3.190.0060.04312.68
5.3.180.0070.03612.67
5.3.170.0010.04012.67
5.3.160.0070.04212.67
5.3.150.0070.04012.68
5.3.140.0070.03512.66
5.3.130.0050.04312.66
5.3.120.0080.03612.66
5.3.110.0080.03512.66
5.3.100.0110.03512.13
5.3.90.0050.03812.11
5.3.80.0070.03412.10
5.3.70.0080.03412.10
5.3.60.0030.03812.09
5.3.50.0060.03612.03
5.3.40.0080.03512.03
5.3.30.0020.03711.99
5.3.20.0060.03511.77
5.3.10.0060.03511.74
5.3.00.0090.03311.73
5.2.170.0080.0279.22
5.2.160.0050.0289.22
5.2.150.0080.0269.23
5.2.140.0030.0319.22
5.2.130.0080.0339.18
5.2.120.0080.0249.18
5.2.110.0040.0329.19
5.2.100.0070.0339.18
5.2.90.0050.0279.18
5.2.80.0030.0329.18
5.2.70.0080.0299.18
5.2.60.0080.0259.14
5.2.50.0030.0319.11
5.2.40.0050.0279.08
5.2.30.0050.0369.05
5.2.20.0050.0279.04
5.2.10.0050.0278.96
5.2.00.0020.0318.83
5.1.60.0050.0228.12
5.1.50.0040.0258.11
5.1.40.0030.0258.09
5.1.30.0030.0328.44
5.1.20.0030.0278.46
5.1.10.0030.0268.19
5.1.00.0070.0278.19
5.0.50.0040.0296.68
5.0.40.0050.0176.54
5.0.30.0040.0316.35
5.0.20.0050.0306.34
5.0.10.0030.0256.31
5.0.00.0050.0286.31
4.4.90.0020.0154.78
4.4.80.0000.0204.76
4.4.70.0020.0164.75
4.4.60.0020.0204.75
4.4.50.0050.0134.77
4.4.40.0040.0244.71
4.4.30.0030.0154.76
4.4.20.0020.0174.84
4.4.10.0050.0134.85
4.4.00.0020.0264.76
4.3.110.0010.0174.67
4.3.100.0030.0144.67
4.3.90.0040.0134.64
4.3.80.0010.0254.60
4.3.70.0040.0134.63
4.3.60.0030.0204.63
4.3.50.0040.0164.63
4.3.40.0000.0294.55
4.3.30.0020.0193.37
4.3.20.0040.0173.35
4.3.10.0050.0153.30
4.3.00.0170.0236.80

preferences:
57.42 ms | 400 KiB | 5 Q