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; echo "\n"; 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.0070.00718.37
8.3.50.0190.00321.92
8.3.40.0110.00418.79
8.3.30.0110.00419.21
8.3.20.0040.00420.38
8.3.10.0080.00023.78
8.3.00.0000.00819.26
8.2.180.0070.01116.50
8.2.170.0110.00422.96
8.2.160.0130.00020.52
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0110.00320.94
8.2.110.0030.00619.45
8.2.100.0120.00017.84
8.2.90.0060.00317.81
8.2.80.0040.00418.16
8.2.70.0030.00518.00
8.2.60.0100.00018.17
8.2.50.0000.01118.10
8.2.40.0000.00920.59
8.2.30.0040.00418.21
8.2.20.0030.00517.87
8.2.10.0040.00418.26
8.2.00.0030.00517.75
8.1.280.0080.00825.92
8.1.270.0050.00322.19
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0090.00022.71
8.1.230.0070.00421.16
8.1.220.0000.00917.79
8.1.210.0040.00419.12
8.1.200.0070.00317.35
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0000.00818.63
8.1.160.0050.00222.22
8.1.150.0000.00718.98
8.1.140.0050.00217.53
8.1.130.0000.00717.94
8.1.120.0050.00317.54
8.1.110.0040.00417.53
8.1.100.0030.00317.55
8.1.90.0070.00017.53
8.1.80.0070.00017.51
8.1.70.0030.00317.46
8.1.60.0100.00017.60
8.1.50.0040.00417.62
8.1.40.0040.00417.47
8.1.30.0040.00417.71
8.1.20.0080.00017.75
8.1.10.0030.00517.55
8.1.00.0040.00417.59
8.0.300.0060.00320.07
8.0.290.0000.00816.63
8.0.280.0000.00818.53
8.0.270.0000.00817.27
8.0.260.0000.00617.29
8.0.250.0030.00317.04
8.0.240.0000.00816.93
8.0.230.0070.00017.01
8.0.220.0000.00716.88
8.0.210.0030.00316.98
8.0.200.0060.00016.89
8.0.190.0060.00316.92
8.0.180.0030.00616.95
8.0.170.0040.00416.90
8.0.160.0040.00416.95
8.0.150.0000.00716.87
8.0.140.0070.00016.85
8.0.130.0060.00313.41
8.0.120.0040.00416.97
8.0.110.0040.00416.93
8.0.100.0000.00716.87
8.0.90.0040.00417.00
8.0.80.0120.00317.02
8.0.70.0050.00216.84
8.0.60.0040.00416.87
8.0.50.0070.00017.01
8.0.30.0120.00817.11
8.0.20.0090.01117.40
8.0.10.0000.00717.06
8.0.00.0150.00416.72
7.4.330.0050.00015.11
7.4.320.0030.00316.73
7.4.300.0060.00016.48
7.4.290.0060.00316.68
7.4.280.0040.00416.68
7.4.270.0030.00316.68
7.4.260.0000.00816.55
7.4.250.0040.00416.69
7.4.240.0020.00516.68
7.4.230.0070.00016.71
7.4.220.0120.00616.69
7.4.210.0100.01016.60
7.4.200.0070.00016.61
7.4.160.0070.01016.68
7.4.150.0120.00817.40
7.4.140.0030.01717.86
7.4.130.0090.01016.57
7.4.120.0090.00816.55
7.4.110.0090.01416.62
7.4.100.0060.00916.83
7.4.90.0160.00716.70
7.4.80.0190.00319.39
7.4.70.0090.00916.47
7.4.60.0000.01616.66
7.4.50.0030.00616.45
7.4.40.0120.00616.65
7.4.30.0110.00516.52
7.4.00.0050.00914.90
7.3.330.0030.00313.30
7.3.320.0060.00013.45
7.3.310.0030.00316.39
7.3.300.0070.00016.39
7.3.290.0070.00616.43
7.3.280.0050.01116.45
7.3.270.0130.00717.40
7.3.260.0040.01216.38
7.3.250.0110.00916.57
7.3.240.0130.00716.72
7.3.230.0030.01316.67
7.3.210.0050.01116.52
7.3.200.0060.01319.39
7.3.190.0090.00816.38
7.3.180.0040.01216.72
7.3.170.0080.00816.70
7.3.160.0070.01016.58
7.3.120.0070.01015.10
7.3.110.0090.00914.97
7.3.100.0100.00314.96
7.3.90.0140.00414.78
7.3.80.0060.00614.73
7.3.70.0100.00314.80
7.3.60.0110.00414.98
7.3.50.0030.01414.69
7.3.40.0060.00914.93
7.3.30.0090.00614.68
7.3.20.0090.00616.50
7.3.10.0060.00916.71
7.3.00.0110.00516.65
7.2.330.0100.00716.68
7.2.320.0000.01716.68
7.2.310.0070.01016.68
7.2.300.0130.00916.83
7.2.290.0110.01116.58
7.2.250.0090.00915.36
7.2.240.0100.00915.36
7.2.230.0030.01415.30
7.2.220.0020.01114.91
7.2.210.0110.00415.08
7.2.200.0140.00014.71
7.2.190.0070.00715.20
7.2.180.0120.00015.05
7.2.170.0060.00615.13
7.2.130.0110.00716.74
7.2.120.0050.00916.78
7.2.110.0080.00716.78
7.2.100.0130.00516.87
7.2.90.0080.00616.71
7.2.80.0050.01016.87
7.2.70.0100.00716.75
7.2.60.0060.00816.72
7.2.50.0100.00716.82
7.2.40.0050.01216.83
7.2.30.0050.01216.91
7.2.20.0080.00816.87
7.2.10.0080.00816.95
7.2.00.0070.00617.84
7.1.330.0000.01515.71
7.1.320.0060.00315.60
7.1.310.0100.00315.89
7.1.300.0070.01015.65
7.1.290.0000.00915.77
7.1.280.0100.00715.70
7.1.270.0040.00815.57
7.1.260.0030.01015.75
7.1.250.0100.00415.85
7.1.240.0130.00615.88
7.1.230.0090.00615.74
7.1.220.0100.00315.40
7.1.210.0060.00915.71
7.1.200.0080.00815.60
7.1.190.0090.00915.77
7.1.180.0090.00615.52
7.1.170.0170.00315.37
7.1.160.0080.00815.65
7.1.150.0110.00615.46
7.1.140.0090.00615.66
7.1.130.0100.00615.71
7.1.120.0060.00915.83
7.1.110.0070.00815.67
7.1.100.0050.01116.83
7.1.90.0160.00315.39
7.1.80.0090.01215.61
7.1.70.0050.00716.42
7.1.60.0120.00817.49
7.1.50.0070.01516.54
7.1.40.0160.00315.81
7.1.30.0170.00315.61
7.1.20.0100.01015.59
7.1.10.0080.00815.74
7.1.00.0030.04319.05
7.0.330.0040.01415.33
7.0.320.0110.00915.16
7.0.310.0130.00515.25
7.0.300.0150.00915.32
7.0.290.0150.00815.38
7.0.280.0150.00815.32
7.0.270.0120.01215.46
7.0.260.0140.00715.29
7.0.250.0120.01215.34
7.0.240.0190.00515.44
7.0.230.0130.01315.16
7.0.220.0140.00715.13
7.0.210.0130.01015.30
7.0.200.0110.00516.00
7.0.190.0110.01415.20
7.0.180.0150.00715.29
7.0.170.0160.00815.28
7.0.160.0100.01015.35
7.0.150.0090.00915.28
7.0.140.0070.04218.62
7.0.130.0200.00915.20
7.0.120.0170.00415.39
7.0.110.0090.00615.35
7.0.100.0110.00915.41
7.0.90.0090.01215.27
7.0.80.0160.00015.22
7.0.70.0150.00415.41
7.0.60.0100.04017.65
7.0.50.0110.02516.67
7.0.40.0080.02416.71
7.0.30.0290.04016.51
7.0.20.0100.03316.74
7.0.10.0090.04316.61
7.0.00.0060.03216.76
5.6.380.0100.00314.26
5.6.370.0040.01114.06
5.6.360.0090.00614.38
5.6.350.0170.00014.25
5.6.340.0030.01314.39
5.6.330.0150.00014.18
5.6.320.0130.00314.10
5.6.310.0050.00914.07
5.6.300.0030.01214.57
5.6.290.0030.00913.84
5.6.280.0070.04117.59
5.6.270.0060.01014.39
5.6.260.0030.01314.01
5.6.250.0070.00414.23
5.6.240.0060.00614.20
5.6.230.0070.00414.63
5.6.220.0080.00314.19
5.6.210.0100.03917.31
5.6.200.0090.04716.18
5.6.190.0050.04717.45
5.6.180.0090.02717.25
5.6.170.0170.03917.34
5.6.160.0090.04517.39
5.6.150.0060.04416.21
5.6.140.0070.02916.16
5.6.130.0050.02316.28
5.6.120.0030.04717.71
5.6.110.0060.04917.56
5.6.100.0050.04917.69
5.6.90.0080.03217.74
5.6.80.0110.03817.21
5.6.70.2390.01917.36
5.6.60.0030.00913.75
5.6.50.0040.00814.17
5.6.40.0000.01813.82
5.6.30.0110.00414.00
5.6.20.0120.00614.24
5.6.10.0000.01314.11
5.6.00.0000.01114.17
5.5.380.0070.00411.14
5.5.370.0060.00311.41
5.5.360.0040.00711.46
5.5.350.0120.02415.81
5.5.340.0050.04314.62
5.5.330.0040.03015.57
5.5.320.0160.02315.74
5.5.310.0130.04515.75
5.5.300.0040.04614.59
5.5.290.0030.02814.66
5.5.280.0020.04715.70
5.5.270.0100.02015.85
5.5.260.0050.02415.89
5.5.250.0080.03915.66
5.5.240.2190.02015.56
5.5.230.0090.00010.95
5.5.220.0040.00710.84
5.5.210.0040.00411.13
5.5.200.0090.00011.12
5.5.190.0080.00711.19
5.5.180.0000.01010.72
5.5.170.0070.00710.74
5.5.160.0100.00311.16
5.5.150.0070.00510.64
5.5.140.0070.00711.19
5.5.130.0070.00710.71
5.5.120.0020.00710.54
5.5.110.0040.00810.83
5.5.100.0070.00711.17
5.5.90.0030.00510.71
5.5.80.0060.00610.79
5.5.70.0080.00310.96
5.5.60.0050.00511.24
5.5.50.0000.01210.89
5.5.40.0030.00711.05
5.5.30.0040.00410.56
5.5.20.0000.00911.10
5.5.10.0040.00710.90
5.5.00.0000.01011.02
5.4.450.0510.02115.10
5.4.440.0410.03415.16
5.4.430.0510.02615.28
5.4.420.0420.03215.23
5.4.410.0450.03215.29
5.4.400.0030.03515.03
5.4.390.0320.03414.90
5.4.380.0130.03215.00
5.4.370.0100.03115.19
5.4.360.0090.03415.09
5.4.350.0090.03515.05
5.4.340.0080.02211.66
5.4.330.0110.00011.15
5.4.320.0040.02511.90
5.4.310.0060.02211.82
5.4.300.0040.02311.92
5.4.290.0090.02111.89
5.4.280.0070.02111.79
5.4.270.0070.02311.70
5.4.260.0090.01811.78
5.4.250.0060.02211.69
5.4.240.0120.01811.63
5.4.230.0080.02011.70
5.4.220.0100.01811.74
5.4.210.0070.02411.79
5.4.200.0100.01911.76
5.4.190.0090.01911.87
5.4.180.0050.02111.68
5.4.170.0060.02111.62
5.4.160.0060.02111.65
5.4.150.0050.02111.71
5.4.140.0060.02011.53
5.4.130.0050.02111.48
5.4.120.0050.02011.60
5.4.110.0080.01711.62
5.4.100.0020.02311.46
5.4.90.0070.01911.55
5.4.80.0020.02111.54
5.4.70.0050.01911.41
5.4.60.0080.01611.39
5.4.50.0020.02411.40
5.4.40.0050.01911.53
5.4.30.0030.02111.38
5.4.20.0050.02511.51
5.4.10.0040.02011.45
5.4.00.0050.02011.04
5.3.290.0050.02611.80
5.3.280.0080.02011.59
5.3.270.0080.02011.73
5.3.260.0060.02211.64
5.3.250.0080.01911.66
5.3.240.0080.01911.49
5.3.230.0050.02111.48
5.3.220.0080.01811.50
5.3.210.0060.02211.47
5.3.200.0040.02211.62
5.3.190.0060.01911.50
5.3.180.0060.02111.56
5.3.170.0050.02211.56
5.3.160.0050.02011.65
5.3.150.0060.02011.56
5.3.140.0070.01811.66
5.3.130.0080.01611.62
5.3.120.0030.02211.62
5.3.110.0040.02211.61
5.3.100.0040.02111.20
5.3.90.0040.02011.38
5.3.80.0080.02311.28
5.3.70.0050.01911.18
5.3.60.0020.02511.35
5.3.50.0060.02111.40
5.3.40.0040.02211.32
5.3.30.0060.02111.38
5.3.20.0050.02111.21
5.3.10.0080.01911.00
5.3.00.0040.02411.06
5.2.170.0030.0259.74
5.2.160.0040.0159.74
5.2.150.0050.0169.74
5.2.140.0020.0199.74
5.2.130.0040.0179.72
5.2.120.0050.0159.72
5.2.110.0070.0149.72
5.2.100.0020.0169.72
5.2.90.0020.0199.72
5.2.80.0040.0189.71
5.2.70.0060.0159.71
5.2.60.0040.0199.70
5.2.50.0030.0229.68
5.2.40.0020.0209.67
5.2.30.0040.0179.65
5.2.20.0050.0209.65
5.2.10.0020.0209.61
5.2.00.0020.0209.54
5.1.60.0080.0109.18
5.1.50.0040.0139.18
5.1.40.0030.0159.17
5.1.30.0060.0179.35
5.1.20.0040.0159.36
5.1.10.0020.0159.22
5.1.00.0020.0179.22
5.0.50.0030.0128.47
5.0.40.0020.0138.40
5.0.30.0030.0188.30
5.0.20.0020.0128.29
5.0.10.0020.0148.28
5.0.00.0050.0158.28
4.4.90.0020.0097.52
4.4.80.0030.0097.51
4.4.70.0020.0107.51
4.4.60.0030.0097.50
4.4.50.0050.0087.51
4.4.40.0030.0137.48
4.4.30.0030.0087.51
4.4.20.0030.0087.55
4.4.10.0050.0087.55
4.4.00.0020.0147.51
4.3.110.0020.0127.46
4.3.100.0040.0097.46
4.3.90.0020.0097.45
4.3.80.0020.0147.43
4.3.70.0040.0087.44
4.3.60.0040.0087.44
4.3.50.0020.0097.44
4.3.40.0020.0147.40
4.3.30.0040.0126.81
4.3.20.0020.0126.80
4.3.10.0030.0116.78
4.3.00.0070.0078.53

preferences:
48.75 ms | 401 KiB | 5 Q