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; return $fraction; } 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.0080.00818.30
8.3.50.0130.00522.09
8.3.40.0110.00718.79
8.3.30.0000.01419.26
8.3.20.0040.00420.51
8.3.10.0050.00323.83
8.3.00.0090.00019.16
8.2.180.0150.00316.50
8.2.170.0120.00922.96
8.2.160.0100.00320.47
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0140.00421.09
8.2.110.0090.00022.24
8.2.100.0130.00017.63
8.2.90.0000.00819.40
8.2.80.0040.00417.97
8.2.70.0030.00617.75
8.2.60.0040.00418.05
8.2.50.0000.00818.07
8.2.40.0000.00820.01
8.2.30.0060.00318.08
8.2.20.0060.00317.84
8.2.10.0030.00518.25
8.2.00.0040.00417.82
8.1.280.0120.00825.92
8.1.270.0000.00822.14
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00023.97
8.1.230.0060.00619.26
8.1.220.0040.00417.89
8.1.210.0080.00018.77
8.1.200.0040.00417.23
8.1.190.0000.00817.22
8.1.180.0000.00718.10
8.1.170.0000.00820.56
8.1.160.0000.00722.09
8.1.150.0030.00518.88
8.1.140.0000.00817.53
8.1.130.0000.00717.99
8.1.120.0070.00017.55
8.1.110.0040.00417.46
8.1.100.0000.00717.58
8.1.90.0000.00717.57
8.1.80.0050.00217.55
8.1.70.0040.00417.48
8.1.60.0120.00017.68
8.1.50.0080.00017.67
8.1.40.0040.00417.63
8.1.30.0040.00417.73
8.1.20.0060.00317.70
8.1.10.0030.00517.66
8.1.00.0000.00717.59
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0040.00418.50
8.0.270.0000.00717.18
8.0.260.0030.00317.41
8.0.250.0030.00316.96
8.0.240.0040.00417.02
8.0.230.0030.00316.97
8.0.220.0020.00516.88
8.0.210.0050.00216.90
8.0.200.0000.00716.96
8.0.190.0040.00416.92
8.0.180.0000.00716.84
8.0.170.0000.00716.88
8.0.160.0040.00416.96
8.0.150.0070.00016.93
8.0.140.0040.00416.89
8.0.130.0060.00013.46
8.0.120.0040.00416.97
8.0.110.0000.00716.89
8.0.100.0040.00416.94
8.0.90.0030.00516.99
8.0.80.0070.01416.96
8.0.70.0030.00516.81
8.0.60.0070.00017.04
8.0.50.0040.00416.88
8.0.30.0150.00517.22
8.0.20.0120.01017.40
8.0.10.0000.00717.21
8.0.00.0090.00716.81
7.4.330.0050.00015.21
7.4.320.0000.00616.59
7.4.300.0000.00616.57
7.4.290.0060.00316.52
7.4.280.0000.00816.62
7.4.270.0030.00316.67
7.4.260.0070.00016.67
7.4.250.0000.00716.56
7.4.240.0050.00216.61
7.4.230.0000.00716.68
7.4.220.0220.00416.65
7.4.210.0040.01116.72
7.4.200.0000.00716.65
7.4.160.0100.00716.34
7.4.150.0150.00317.40
7.4.140.0130.00717.86
7.4.130.0140.00516.62
7.4.120.0130.00416.51
7.4.110.0190.00316.51
7.4.100.0100.00616.53
7.4.90.0030.01516.68
7.4.80.0060.01019.39
7.4.70.0150.00416.64
7.4.60.0130.00316.36
7.4.50.0030.00616.43
7.4.40.0070.01016.71
7.4.30.0130.00316.51
7.4.00.0100.00315.17
7.3.330.0050.00013.43
7.3.320.0030.00313.51
7.3.310.0070.00016.47
7.3.300.0020.00516.31
7.3.290.0050.00916.43
7.3.280.0090.01116.45
7.3.270.0140.01217.40
7.3.260.0090.00916.72
7.3.250.0100.00916.42
7.3.240.0140.00616.65
7.3.230.0080.00816.72
7.3.210.0080.01116.45
7.3.200.0090.01219.39
7.3.190.0100.00716.40
7.3.180.0080.00816.36
7.3.170.0140.00716.59
7.3.160.0030.01416.60
7.2.330.0120.00616.66
7.2.320.0120.01116.87
7.2.310.0130.00316.51
7.2.300.0090.00616.86
7.2.290.0090.01316.62
7.2.60.0070.00716.86
7.2.00.0060.00619.57
7.1.200.0130.00015.91
7.1.100.0000.01218.17
7.1.70.0210.00016.88
7.1.60.0120.01219.32
7.1.50.0040.01516.69
7.1.00.0070.07322.30
7.0.200.0040.01116.81
7.0.140.0030.07321.98
7.0.60.0130.08019.92
7.0.50.0100.08017.73
7.0.40.0100.04020.16
7.0.30.0600.05720.09
7.0.20.0370.07320.19
7.0.10.0070.05720.19
7.0.00.0070.04020.23
5.6.280.0070.07021.05
5.6.210.0070.07720.65
5.6.200.0030.08018.19
5.6.190.0030.05020.67
5.6.180.0130.08320.48
5.6.170.0400.06720.44
5.6.160.0130.05720.40
5.6.150.0100.04318.27
5.6.140.0130.07718.18
5.6.130.0030.05018.18
5.6.120.0130.06721.02
5.6.110.0200.06721.01
5.6.100.0130.07321.02
5.6.90.0100.05320.97
5.6.80.0030.04020.43
5.6.70.4170.03720.38
5.5.350.0130.03720.43
5.5.340.0130.07717.99
5.5.330.0200.07020.43
5.5.320.0230.03720.32
5.5.310.0230.08320.24
5.5.300.0030.04017.98
5.5.290.0070.04717.98
5.5.280.0070.08320.96
5.5.270.0170.07320.88
5.5.260.0070.08720.77
5.5.250.0030.08720.64
5.5.240.2130.03720.27
5.4.450.0800.04719.47
5.4.440.0930.05319.61
5.4.430.0200.05019.35
5.4.420.0200.05019.64
5.4.410.0700.06719.25
5.4.400.0730.04718.98
5.4.390.0870.06019.30
5.4.380.0770.06319.05
5.4.370.0630.05719.12
5.4.360.0370.05319.06
5.4.350.0700.05319.27
5.4.340.0080.03712.02
5.4.320.0060.03612.51
5.4.310.0040.03812.51
5.4.300.0100.03612.51
5.4.290.0050.03712.50
5.4.280.0070.03712.40
5.4.270.0040.04312.40
5.4.260.0040.04312.40
5.4.250.0050.04412.40
5.4.240.0110.03112.41
5.4.230.0070.03412.39
5.4.220.0060.03412.39
5.4.210.0080.03312.39
5.4.200.0080.03912.39
5.4.190.0060.03712.39
5.4.180.0050.03612.39
5.4.170.0020.03912.40
5.4.160.0050.03512.39
5.4.150.0040.03712.39
5.4.140.0060.03712.07
5.4.130.0050.03512.07
5.4.120.0100.03012.02
5.4.110.0050.03512.02
5.4.100.0050.03512.02
5.4.90.0050.04012.02
5.4.80.0050.03712.02
5.4.70.0070.03312.01
5.4.60.0050.03612.02
5.4.50.0090.03712.01
5.4.40.0080.03812.00
5.4.30.0070.03712.00
5.4.20.0090.03812.00
5.4.10.0050.03512.00
5.4.00.0060.03411.49
5.3.290.0100.03812.80
5.3.280.0060.03812.71
5.3.270.0060.03812.72
5.3.260.0090.03512.72
5.3.250.0090.03212.72
5.3.240.0080.03312.71
5.3.230.0060.03612.71
5.3.220.0050.03812.68
5.3.210.0080.03712.68
5.3.200.0060.03512.68
5.3.190.0080.04312.68
5.3.180.0060.03712.67
5.3.170.0030.03812.67
5.3.160.0050.03612.67
5.3.150.0100.03312.67
5.3.140.0070.03612.66
5.3.130.0060.03912.66
5.3.120.0050.04512.66
5.3.110.0070.04012.66
5.3.100.0060.03712.13
5.3.90.0040.03812.11
5.3.80.0090.03912.10
5.3.70.0060.04012.10
5.3.60.0080.03512.09
5.3.50.0070.03512.03
5.3.40.0090.03412.03
5.3.30.0060.04211.99
5.3.20.0030.03811.77
5.3.10.0050.03511.74
5.3.00.0050.03611.73
5.2.170.0020.0339.22
5.2.160.0040.0369.23
5.2.150.0060.0349.22
5.2.140.0070.0429.22
5.2.130.0030.0319.18
5.2.120.0050.0289.18
5.2.110.0050.0319.19
5.2.100.0050.0299.19
5.2.90.0070.0279.18
5.2.80.0050.0299.18
5.2.70.0050.0309.18
5.2.60.0010.0339.14
5.2.50.0070.0289.11
5.2.40.0070.0269.08
5.2.30.0050.0299.05
5.2.20.0020.0309.05
5.2.10.0040.0288.96
5.2.00.0050.0298.84
5.1.60.0050.0238.11
5.1.50.0050.0298.11
5.1.40.0070.0278.09
5.1.30.0050.0258.44
5.1.20.0060.0288.46
5.1.10.0060.0298.18
5.1.00.0070.0268.19
5.0.50.0030.0216.68
5.0.40.0030.0226.54
5.0.30.0030.0336.36
5.0.20.0020.0216.34
5.0.10.0040.0206.31
5.0.00.0040.0316.31
4.4.90.0080.0164.78
4.4.80.0090.0104.75
4.4.70.0030.0174.75
4.4.60.0040.0164.75
4.4.50.0040.0154.77
4.4.40.0040.0254.71
4.4.30.0030.0184.76
4.4.20.0040.0174.85
4.4.10.0040.0154.84
4.4.00.0000.0274.76
4.3.110.0020.0164.67
4.3.100.0040.0144.66
4.3.90.0030.0144.63
4.3.80.0040.0234.61
4.3.70.0050.0124.63
4.3.60.0020.0194.63
4.3.50.0020.0194.62
4.3.40.0010.0274.56
4.3.30.0030.0153.37
4.3.20.0040.0153.35
4.3.10.0020.0163.30
4.3.00.0170.0206.80

preferences:
38.8 ms | 400 KiB | 5 Q