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]; $denomenator = $num_array[1]; $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.0120.00318.68
8.3.50.0140.00821.82
8.3.40.0170.00018.83
8.3.30.0030.01019.01
8.3.20.0050.00220.41
8.3.10.0120.00323.83
8.3.00.0060.00319.36
8.2.180.0160.00616.63
8.2.170.0090.00622.96
8.2.160.0030.01020.25
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0030.00526.16
8.2.120.0140.00020.81
8.2.110.0090.00022.29
8.2.100.0040.00817.75
8.2.90.0000.00819.07
8.2.80.0000.00817.97
8.2.70.0030.00517.50
8.2.60.0040.00418.05
8.2.50.0070.00318.07
8.2.40.0030.00618.28
8.2.30.0070.00018.33
8.2.20.0050.00317.87
8.2.10.0000.00718.23
8.2.00.0080.00317.91
8.1.280.0180.00425.92
8.1.270.0000.00822.14
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00022.60
8.1.230.0070.00419.22
8.1.220.0040.00417.75
8.1.210.0000.00818.77
8.1.200.0080.00417.48
8.1.190.0040.00417.25
8.1.180.0000.00818.10
8.1.170.0040.00418.50
8.1.160.0040.00422.04
8.1.150.0040.00418.91
8.1.140.0000.00717.47
8.1.130.0000.00717.98
8.1.120.0000.00817.49
8.1.110.0050.00317.47
8.1.100.0040.00417.37
8.1.90.0030.00317.43
8.1.80.0050.00217.36
8.1.70.0050.00217.45
8.1.60.0110.00217.56
8.1.50.0000.00917.59
8.1.40.0050.00317.55
8.1.30.0000.00817.76
8.1.20.0040.00417.64
8.1.10.0020.00517.64
8.1.00.0040.00417.54
8.0.300.0080.00018.77
8.0.290.0050.00216.75
8.0.280.0030.00318.43
8.0.270.0030.00317.30
8.0.260.0000.00617.20
8.0.250.0070.00017.05
8.0.240.0040.00417.07
8.0.230.0050.00317.06
8.0.220.0040.00416.99
8.0.210.0030.00316.91
8.0.200.0000.00717.10
8.0.190.0000.00817.02
8.0.180.0000.00817.09
8.0.170.0050.00316.95
8.0.160.0040.00417.07
8.0.150.0000.00716.87
8.0.140.0070.00016.91
8.0.130.0040.00413.44
8.0.120.0020.00517.00
8.0.110.0000.00817.10
8.0.100.0000.00717.00
8.0.90.0080.00016.91
8.0.80.0060.01016.96
8.0.70.0000.00816.99
8.0.60.0050.00217.04
8.0.50.0050.00216.98
8.0.30.0130.00617.18
8.0.20.0090.00917.44
8.0.10.0020.00516.95
8.0.00.0120.00616.78
7.4.330.0000.00515.05
7.4.320.0030.00316.69
7.4.300.0030.00316.59
7.4.290.0060.00316.68
7.4.280.0080.00016.59
7.4.270.0000.00716.69
7.4.260.0000.00816.61
7.4.250.0000.00816.65
7.4.240.0030.00316.60
7.4.230.0040.00416.78
7.4.220.0090.00916.64
7.4.210.0030.01216.62
7.4.200.0040.00416.66
7.4.160.0090.00616.62
7.4.150.0120.00617.40
7.4.140.0180.00517.86
7.4.130.0050.01516.60
7.4.120.0050.01216.53
7.4.110.0140.00916.58
7.4.100.0100.00716.50
7.4.90.0060.01216.73
7.4.80.0070.01019.39
7.4.70.0170.00616.63
7.4.60.0040.01316.59
7.4.50.0040.00016.66
7.4.40.0070.00716.63
7.4.30.0070.01016.70
7.4.00.0070.01115.05
7.3.330.0060.00013.45
7.3.320.0000.00513.47
7.3.310.0070.00016.55
7.3.300.0030.00316.55
7.3.290.0070.01116.48
7.3.280.0110.00816.51
7.3.270.0090.00917.40
7.3.260.0130.00316.63
7.3.250.0080.00916.59
7.3.240.0180.00616.57
7.3.230.0050.01116.69
7.3.210.0060.01016.42
7.3.200.0080.00819.39
7.3.190.0070.01316.56
7.3.180.0080.00816.68
7.3.170.0080.00816.61
7.3.160.0160.00016.59
7.3.120.0080.00815.11
7.3.110.0080.01014.73
7.3.100.0110.00314.82
7.3.90.0070.00814.73
7.3.80.0070.00914.97
7.3.70.0030.00814.92
7.3.60.0050.00714.96
7.3.50.0080.00314.77
7.3.40.0100.00514.54
7.3.30.0070.00914.96
7.3.20.0070.00916.70
7.3.10.0070.00816.79
7.3.00.0050.00716.66
7.2.330.0060.01216.89
7.2.320.0060.01216.89
7.2.310.0100.00716.67
7.2.300.0030.01316.86
7.2.290.0160.00716.86
7.2.250.0070.01315.16
7.2.240.0080.01114.95
7.2.230.0090.00514.74
7.2.220.0050.00815.03
7.2.210.0070.00515.02
7.2.200.0050.01014.90
7.2.190.0070.00815.00
7.2.180.0040.01114.91
7.2.170.0100.00614.97
7.2.130.0030.00917.00
7.2.120.0030.01016.76
7.2.110.0070.00516.90
7.2.100.0060.00416.96
7.2.90.0100.00316.79
7.2.80.0090.00516.85
7.2.70.0030.01216.93
7.2.60.0040.00817.12
7.2.50.0050.00716.83
7.2.40.0020.00916.84
7.2.30.0060.00617.09
7.2.20.0020.01216.97
7.2.10.0040.00916.89
7.2.00.0080.00817.73
7.1.330.0020.01115.60
7.1.320.0080.00415.89
7.1.310.0040.00815.77
7.1.300.0030.01015.82
7.1.290.0020.00915.49
7.1.280.0030.01015.68
7.1.270.0030.01115.88
7.1.260.0040.00915.94
7.1.250.0070.00515.55
7.1.240.0040.00715.83
7.1.230.0090.00615.91
7.1.220.0000.00915.66
7.1.210.0070.00315.95
7.1.200.0070.00715.58
7.1.190.0060.00615.71
7.1.180.0040.01115.76
7.1.170.0000.00815.86
7.1.160.0060.00315.69
7.1.150.0060.00615.68
7.1.140.0090.00915.92
7.1.130.0080.00415.43
7.1.120.0000.01015.88
7.1.110.0110.00415.91
7.1.100.0080.00616.77
7.1.90.0000.01515.99
7.1.80.0000.01115.75
7.1.70.0060.00616.47
7.1.60.0130.00717.54
7.1.50.0080.01116.24
7.1.40.0110.00315.85
7.1.30.0070.00715.84
7.1.20.0100.00015.77
7.1.10.0110.00315.69
7.1.00.0050.03819.15
7.0.330.0060.00315.57
7.0.320.0100.00315.24
7.0.310.0000.01215.41
7.0.300.0030.01015.51
7.0.290.0070.01015.34
7.0.280.0040.00815.22
7.0.270.0070.00715.14
7.0.260.0080.00815.09
7.0.250.0060.00915.41
7.0.240.0130.00015.46
7.0.230.0090.00015.16
7.0.220.0030.01015.36
7.0.210.0040.00715.47
7.0.200.0080.00716.09
7.0.190.0030.01015.23
7.0.180.0000.01115.43
7.0.170.0030.00515.21
7.0.160.0030.01015.11
7.0.150.0030.00615.56
7.0.140.0050.03818.64
7.0.130.0060.01215.14
7.0.120.0030.00715.32
7.0.110.0040.00415.32
7.0.100.0110.02517.62
7.0.90.0200.04017.63
7.0.80.0150.03417.76
7.0.70.0090.04317.54
7.0.60.0000.03117.70
7.0.50.0020.04017.92
7.0.40.0050.03716.73
7.0.30.0030.05016.67
7.0.20.0060.03316.80
7.0.10.0120.04216.73
7.0.00.0130.04116.66
5.6.380.0120.00314.50
5.6.370.0080.00414.20
5.6.360.0000.01014.05
5.6.350.0060.00614.33
5.6.340.0190.00314.54
5.6.330.0140.00014.64
5.6.320.0000.01414.11
5.6.310.0040.00714.21
5.6.300.0060.00614.33
5.6.290.0060.00614.23
5.6.280.0070.03817.86
5.6.270.0070.01014.61
5.6.260.0060.01314.55
5.6.250.0100.03117.55
5.6.240.0130.03717.51
5.6.230.0130.04017.44
5.6.220.0060.04717.24
5.6.210.0050.03117.42
5.6.200.0100.04317.68
5.6.190.0080.02817.55
5.6.180.0120.03317.52
5.6.170.0040.04617.68
5.6.160.0090.04217.66
5.6.150.0060.04617.75
5.6.140.0060.04217.79
5.6.130.0150.02717.59
5.6.120.0050.04517.59
5.6.110.0110.04017.53
5.6.100.0050.03017.50
5.6.90.0030.03617.59
5.6.80.0100.04517.48
5.6.70.0130.04717.43
5.6.60.0250.02517.37
5.6.50.0090.02217.48
5.6.40.0050.02917.38
5.6.30.0070.02317.50
5.6.20.0020.02517.38
5.6.10.0130.02017.30
5.6.00.0100.01617.28
5.5.380.0100.04215.83
5.5.370.0060.04115.78
5.5.360.0080.03415.71
5.5.350.0080.04315.86
5.5.340.0130.03815.95
5.5.330.0060.02615.98
5.5.320.0060.04115.86
5.5.310.0050.04315.90
5.5.300.0060.02515.96
5.5.290.0050.02815.87
5.5.280.0020.04515.88
5.5.270.0100.04315.93
5.5.260.0050.04216.02
5.5.250.0010.04415.89
5.5.240.0110.03715.71
5.5.230.0080.04515.76
5.5.220.0110.02115.64
5.5.210.0080.02015.70
5.5.200.0090.02115.48
5.5.190.0080.02715.64
5.5.180.0050.02515.62
5.5.170.0030.00610.50
5.5.160.0050.02215.72
5.5.150.0070.02215.74
5.5.140.0090.02015.53
5.5.130.0050.02815.66
5.5.120.0080.03315.63
5.5.110.0050.02215.49
5.5.100.0110.02015.51
5.5.90.0140.02215.44
5.5.80.0050.02015.64
5.5.70.0080.02215.52
5.5.60.0110.02015.63
5.5.50.0100.01715.53
5.5.40.0100.02215.59
5.5.30.0190.02015.28
5.5.20.0110.02215.50
5.5.10.0080.02515.32
5.5.00.0070.02515.55
5.4.450.0020.04815.04
5.4.440.0080.04315.20
5.4.430.0020.03315.05
5.4.420.0100.03915.09
5.4.410.0080.04214.99
5.4.400.0100.02014.99
5.4.390.0030.04115.08
5.4.380.0070.02014.91
5.4.370.0050.02314.99
5.4.360.0070.03114.97
5.4.350.0130.02014.97
5.4.340.0090.02015.05
5.4.330.0070.01010.87
5.4.320.0060.02515.01
5.4.310.0080.01814.90
5.4.300.0070.02314.95
5.4.290.0120.02015.06
5.4.280.0080.02315.11
5.4.270.0020.02214.89
5.4.260.0080.02014.94
5.4.250.0060.02014.92
5.4.240.0080.02014.97
5.4.230.0130.02915.04
5.4.220.0120.02115.22
5.4.210.0130.01814.99
5.4.200.0110.02314.99
5.4.190.0080.02215.02
5.4.180.0150.02414.93
5.4.170.0050.01515.12
5.4.160.0080.02514.96
5.4.150.0030.02115.01
5.4.140.0060.02313.69
5.4.130.0070.01713.74
5.4.120.0050.02013.56
5.4.110.0030.02113.50
5.4.100.0110.01313.76
5.4.90.0070.01813.72
5.4.80.0080.01713.72
5.4.70.0070.01813.85
5.4.60.0130.01613.56
5.4.50.0090.02813.74
5.4.40.0030.02213.40
5.4.30.0060.02213.57
5.4.20.0060.02113.59
5.4.10.0080.04113.44
5.4.00.0090.03313.23
5.3.290.0070.02012.72
5.3.280.0050.02312.64
5.3.270.0050.02212.53
5.3.260.0070.01912.62
5.3.250.0030.02312.52
5.3.240.0020.02412.65
5.3.230.0000.02812.56
5.3.220.0020.02412.52
5.3.210.0040.02412.59
5.3.200.0040.02112.49
5.3.190.0030.02312.51
5.3.180.0040.02012.59
5.3.170.0030.02212.74
5.3.160.0050.01912.65
5.3.150.0020.04712.65
5.3.140.0020.02612.61
5.3.130.0090.02612.48
5.3.120.0030.02312.46
5.3.110.0070.04212.44
5.3.100.0080.03812.38
5.3.90.0110.02412.45
5.3.80.0090.04112.26
5.3.70.0070.02412.21
5.3.60.0100.04012.28
5.3.50.0160.01912.23
5.3.40.0080.01812.14
5.3.30.0070.03712.34
5.3.20.0060.02312.05
5.3.10.0160.03311.99
5.3.00.0080.02311.97
5.2.170.0000.02510.90
5.2.160.0110.02210.96
5.2.150.0070.03710.91
5.2.140.0080.02710.92
5.2.130.0020.03510.88
5.2.120.0080.01710.96
5.2.110.0070.01910.90
5.2.100.0130.03110.89
5.2.90.0120.01510.90
5.2.80.0090.03410.88
5.2.70.0110.02010.83
5.2.60.0100.02510.84
5.2.50.0030.03010.88
5.2.40.0060.02710.92
5.2.30.0050.02810.87
5.2.20.0070.03010.83
5.2.10.0050.02710.83
5.2.00.0020.03510.83
5.1.60.0070.02410.83
5.1.50.0060.02510.83
5.1.40.0040.02410.83
5.1.30.0070.02710.83
5.1.20.0060.02610.83
5.1.10.0040.02210.83
5.1.00.0060.02910.83
5.0.50.0030.01810.83
5.0.40.0000.02210.83
5.0.30.0030.03510.83
5.0.20.0070.00910.83
5.0.10.0020.01710.83
5.0.00.0030.02810.83
4.4.90.0020.02010.83
4.4.80.0020.01810.83
4.4.70.0020.01510.83
4.4.60.0060.01510.83
4.4.50.0000.02110.83
4.4.40.0000.02610.83
4.4.30.0020.02110.83
4.4.20.0040.02010.83
4.4.10.0050.01810.83
4.4.00.0070.02310.83
4.3.110.0030.01710.83
4.3.100.0050.01810.83
4.3.90.0040.01210.83
4.3.80.0060.01310.83
4.3.70.0000.01810.83
4.3.60.0030.00910.83
4.3.50.0050.01710.83
4.3.40.0030.02810.83
4.3.30.0030.02010.83
4.3.20.0020.01810.83
4.3.10.0020.02010.83
4.3.00.0050.01310.83

preferences:
35.75 ms | 401 KiB | 5 Q