3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Immutable class for handling numbers with precision. * * Never change the $number or the $precision after the creation of the object. */ class DecimalNumber { private $precision; private $number; /** * Get an instance given a string and a precision * @param string $string The decimal number in string form * @param int $precision The precision of the number * @return DecimalNumber Return new instance */ public static function createWithString($string, $precision = 4) { $me = get_called_class(); $number = new $me; $number->precision = $precision; $number->number = bcadd($string, '0', $precision); return $number; } /** * Perform an addition operation * @param DecimalNumber $number the number to add * @return DecimalNumber Return the sum */ public function add(DecimalNumber $number) { return DecimalNumber::decimalNumberWithString(bcadd($this->number, $number, $this->precision)); } /** * Automagically convert to a string * @return string returns a string containing the value of this DecimalNumber */ public function __toString() { return $this->number; } } $d = DecimalNumber::createWithString('.7'); echo $d->add(DecimalNumber::createWithString('.1'));

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.0200.00018.68
8.3.50.0120.00521.15
8.3.40.0110.00718.99
8.3.30.0070.00718.91
8.3.20.0080.00018.90
8.3.10.0080.00021.12
8.3.00.0080.00019.68
8.2.180.0120.00317.00
8.2.170.0100.00722.96
8.2.160.0100.00320.57
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0070.00026.16
8.2.120.0070.00021.05
8.2.110.0070.00420.35
8.2.100.0090.00317.91
8.2.90.0040.00419.13
8.2.80.0080.00019.32
8.2.70.0000.00817.63
8.2.60.0050.00318.04
8.2.50.0040.00418.07
8.2.40.0000.00718.28
8.2.30.0000.00721.23
8.2.20.0050.00217.55
8.2.10.0040.00417.76
8.2.00.0030.00617.64
8.1.280.0100.00325.92
8.1.270.0000.00823.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00023.93
8.1.230.0110.00022.75
8.1.220.0040.00418.77
8.1.210.0040.00419.03
8.1.200.0070.00317.35
8.1.190.0040.00417.39
8.1.180.0000.00918.10
8.1.170.0050.00318.43
8.1.160.0000.00718.78
8.1.150.0030.00518.61
8.1.140.0000.00717.53
8.1.130.0030.00517.76
8.1.120.0040.00317.54
8.1.110.0070.00017.36
8.1.100.0050.00217.53
8.1.90.0040.00417.38
8.1.80.0050.00317.53
8.1.70.0000.00717.36
8.1.60.0030.00617.63
8.1.50.0000.00717.40
8.1.40.0060.00317.53
8.1.30.0070.00017.55
8.1.20.0000.00917.58
8.1.10.0000.00717.61
8.1.00.0030.00617.53
8.0.300.0080.00019.88
8.0.290.0040.00417.05
8.0.280.0000.00718.47
8.0.270.0070.00017.34
8.0.260.0000.00716.91
8.0.250.0000.00816.92
8.0.240.0050.00316.91
8.0.230.0000.00717.05
8.0.220.0070.00016.93
8.0.210.0040.00416.84
8.0.200.0000.00717.03
8.0.190.0000.00717.08
8.0.180.0040.00416.89
8.0.170.0000.00716.87
8.0.160.0080.00016.99
8.0.150.0040.00416.94
8.0.140.0030.00316.99
8.0.130.0000.00613.45
8.0.120.0040.00416.98
8.0.110.0040.00416.75
8.0.100.0040.00416.95
8.0.90.0000.00716.89
8.0.80.0040.01616.98
8.0.70.0000.00717.02
8.0.60.0070.00016.93
8.0.50.0040.00416.82
8.0.30.0090.00917.21
8.0.20.0100.00817.40
8.0.10.0000.00816.91
8.0.00.0110.00616.88
7.4.330.0050.00016.79
7.4.320.0000.00616.47
7.4.300.0020.00516.52
7.4.290.0030.00316.64
7.4.280.0070.00016.48
7.4.270.0000.00816.61
7.4.260.0030.00313.32
7.4.250.0000.00716.47
7.4.240.0000.00716.52
7.4.230.0030.00316.44
7.4.220.0130.00316.50
7.4.210.0080.01016.61
7.4.200.0050.00316.43
7.4.190.0030.00316.49
7.4.160.0030.01316.54
7.4.150.0070.01117.40
7.4.140.0050.01217.86
7.4.130.0110.00716.50
7.4.120.0130.00516.64
7.4.110.0100.00716.73
7.4.100.0100.00616.57
7.4.90.0120.00616.44
7.4.80.0140.00319.39
7.4.70.0140.00416.35
7.4.60.0090.01316.64
7.4.50.0080.00016.32
7.4.40.0060.00922.77
7.4.30.0160.00716.61
7.4.10.0120.00414.84
7.4.00.0050.01114.99
7.3.330.0070.00013.27
7.3.320.0000.00513.24
7.3.310.0000.00716.41
7.3.300.0030.00316.43
7.3.290.0060.00916.39
7.3.280.0100.00916.43
7.3.270.0120.00617.40
7.3.260.0130.00718.24
7.3.250.0080.00916.54
7.3.240.0060.01016.36
7.3.230.0130.00316.67
7.3.210.0130.00316.35
7.3.200.0070.01319.39
7.3.190.0090.00916.71
7.3.180.0040.01116.59
7.3.170.0080.00816.49
7.3.160.0090.01316.40
7.3.130.0030.01514.96
7.3.120.0020.01514.77
7.3.110.0090.00914.98
7.3.100.0070.00714.93
7.3.90.0060.01114.84
7.3.80.0060.00914.86
7.3.70.0070.00714.81
7.3.60.0060.00914.75
7.3.50.0080.00414.85
7.3.40.0090.00414.80
7.3.30.0040.00914.72
7.3.20.0100.00316.68
7.3.10.0040.01316.77
7.3.00.0070.00616.60
7.2.330.0070.01116.61
7.2.320.0030.01316.66
7.2.310.0110.00716.37
7.2.300.0080.01116.80
7.2.290.0060.01016.84
7.2.260.0030.01214.74
7.2.250.0100.00915.11
7.2.240.0070.01014.92
7.2.230.0040.01214.82
7.2.220.0110.00614.99
7.2.210.0060.00814.99
7.2.200.0040.00814.93
7.2.190.0070.00814.84
7.2.180.0080.00514.81
7.2.170.0020.01214.98
7.2.160.0050.00714.98
7.2.150.0080.00916.90
7.2.140.0060.01016.71
7.2.130.0080.00516.77
7.2.120.0020.01216.92
7.2.110.0100.00716.78
7.2.100.0030.01116.85
7.2.90.0070.00516.78
7.2.80.0020.01316.87
7.2.70.0050.00916.90
7.2.60.0040.00916.87
7.2.50.0090.00716.77
7.2.40.0030.01216.89
7.2.30.0090.00516.92
7.2.20.0070.01216.92
7.2.10.0080.00916.79
7.2.00.0070.00817.57
7.1.330.0060.00715.73
7.1.320.0090.00815.75
7.1.310.0030.00815.81
7.1.300.0060.00815.71
7.1.290.0070.00615.74
7.1.280.0050.00915.61
7.1.270.0050.00915.77
7.1.260.0100.00515.85
7.1.250.0020.01215.81
7.1.240.0040.01315.72
7.1.230.0070.00715.82
7.1.220.0070.00615.80
7.1.210.0030.01015.81
7.1.200.0040.01015.78
7.1.190.0050.00715.75
7.1.180.0080.00615.88
7.1.170.0090.00315.64
7.1.160.0040.00715.84
7.1.150.0080.00615.81
7.1.140.0040.01015.91
7.1.130.0060.00515.88
7.1.120.0050.00715.87
7.1.110.0070.00615.64
7.1.100.0080.00515.68
7.1.90.0050.00815.83
7.1.80.0070.00615.65
7.1.70.0070.00516.14
7.1.60.0060.00516.33
7.1.50.0050.00715.95
7.1.40.0010.01116.05
7.1.30.0020.01016.03
7.1.20.0020.00816.19
7.1.10.0040.01116.10
7.1.00.0050.00716.04
7.0.330.0030.01015.48
7.0.320.0070.00415.45
7.0.310.0040.00915.35
7.0.300.0050.00915.37
7.0.290.0030.00815.34
7.0.280.0060.00715.39
7.0.270.0070.00715.26
7.0.260.0050.00715.44
7.0.250.0040.00715.45
7.0.240.0020.01215.32
7.0.230.0060.00515.43
7.0.220.0070.01015.40
7.0.210.0030.00915.45
7.0.200.0030.00715.78
7.0.190.0040.00616.01
7.0.180.0060.00715.79
7.0.170.0050.00615.80
7.0.160.0030.00615.72
7.0.150.0010.01015.57
7.0.140.0050.00815.68
7.0.130.0030.00515.73
7.0.120.0020.00915.88
7.0.110.0060.00515.64
7.0.100.0040.00615.69
7.0.90.0060.00915.62
7.0.80.0050.01015.67
7.0.70.0100.00215.79
7.0.60.0080.00515.60
7.0.50.0020.00715.81
7.0.40.0030.00914.15
7.0.30.0020.00914.25
7.0.20.0030.00914.18
7.0.10.0060.00614.04
7.0.00.0010.01014.19
5.6.400.0040.01314.27
5.6.390.0060.00714.48
5.6.380.0060.00714.48
5.6.370.0030.01114.43
5.6.360.0050.00714.47
5.6.350.0040.00614.29
5.6.340.0050.01014.35
5.6.330.0080.00714.35
5.6.320.0040.00514.31
5.6.310.0030.00814.48
5.6.300.0020.03116.51
5.6.290.0020.02216.60
5.6.280.0060.01816.56
5.6.270.0030.01916.58
5.6.260.0020.03116.44
5.6.250.0030.02216.56
5.6.240.0040.02016.72
5.6.230.0030.02316.54
5.6.220.0090.01716.44
5.6.210.0080.01516.59
5.6.200.0010.02216.60
5.6.190.0000.02516.55
5.6.180.0040.02116.50
5.6.170.0020.02416.41
5.6.160.0060.01916.39
5.6.150.0060.01916.40
5.6.140.0070.01916.68
5.6.130.0040.02016.56
5.6.120.0050.02016.49
5.6.110.0090.01816.54
5.6.100.0110.01516.42
5.6.90.0080.01716.55
5.6.80.0030.02516.27
5.6.70.0050.01716.12
5.6.60.0070.01916.30
5.6.50.0040.01916.29
5.6.40.0090.01916.19
5.6.30.0050.03116.31
5.6.20.0070.01816.37
5.6.10.0060.01616.26
5.6.00.0050.02116.23
5.5.380.0050.01815.34
5.5.370.0060.01915.45
5.5.360.0060.02315.41
5.5.350.0060.02115.29
5.5.340.0080.01715.56
5.5.330.0050.02115.46
5.5.320.0050.01615.57
5.5.310.0110.01815.59
5.5.300.0020.02415.56
5.5.290.0080.01715.58
5.5.280.0030.02215.67
5.5.270.0070.02315.48
5.5.260.0140.01515.45
5.5.250.0030.02115.53
5.5.240.0080.01715.35
5.5.230.0050.02015.12
5.5.220.0010.02115.27
5.5.210.0050.01815.21
5.5.200.0050.02115.20
5.5.190.0070.01615.21
5.5.180.0040.01815.25
5.5.170.0050.00814.26
5.5.160.0070.01615.40
5.5.150.0040.02115.34
5.5.140.0080.02115.20
5.5.130.0060.01715.14
5.5.120.0100.02615.22
5.5.110.0070.02815.32
5.5.100.0030.02415.44
5.5.90.0060.02815.29
5.5.80.0110.02015.22
5.5.70.0040.01915.14
5.5.60.0070.01815.34
5.5.50.0060.01615.16
5.5.40.0030.02015.31
5.5.30.0050.02415.27
5.5.20.0030.02015.09
5.5.10.0040.01715.08
5.5.00.0030.01915.07
5.4.450.0030.01814.03
5.4.440.0030.02214.15
5.4.430.0050.01814.10
5.4.420.0050.01814.09
5.4.410.0020.02014.09
5.4.400.0020.02013.85
5.4.390.0030.02013.88
5.4.380.0050.01613.95
5.4.370.0040.01713.93
5.4.360.0080.01113.85
5.4.350.0080.01414.14
5.4.340.0060.01513.91
5.4.330.0060.00611.56
5.4.320.0060.01513.98
5.4.310.0060.01514.09
5.4.300.0060.01514.03
5.4.290.0050.01613.87
5.4.280.0030.02913.88
5.4.270.0090.01814.02
5.4.260.0060.02713.87
5.4.250.0080.01213.90
5.4.240.0040.01813.90
5.4.230.0030.01713.94
5.4.220.0050.01713.91
5.4.210.0050.01713.95
5.4.200.0040.01513.90
5.4.190.0070.01613.83
5.4.180.0040.01613.88
5.4.170.0010.02213.94
5.4.160.0050.01413.94
5.4.150.0050.01813.94
5.4.140.0060.01413.04
5.4.130.0010.01713.21
5.4.120.0050.01613.12
5.4.110.0020.02013.24
5.4.100.0060.01613.12
5.4.90.0120.01713.22
5.4.80.0070.01313.16
5.4.70.0040.02313.24
5.4.60.0050.01413.16
5.4.50.0020.02713.20
5.4.40.0050.01913.16
5.4.30.0040.01813.10
5.4.20.0030.01713.23
5.4.10.0020.01813.14
5.4.00.0040.01612.93
5.3.290.0030.01912.66
5.3.280.0030.01612.59
5.3.270.0040.01712.65
5.3.260.0070.01612.65
5.3.250.0100.01412.57
5.3.240.0040.01712.61
5.3.230.0060.02112.60
5.3.220.0060.01412.59
5.3.210.0040.01712.58
5.3.200.0050.01412.59
5.3.190.0050.01712.60
5.3.180.0030.01712.62
5.3.170.0040.01512.60
5.3.160.0060.01612.65
5.3.150.0050.01412.63
5.3.140.0040.01812.58
5.3.130.0040.01912.62
5.3.120.0060.01512.62
5.3.110.0040.01412.54
5.3.100.0030.01712.64
5.3.90.0040.01512.68
5.3.80.0040.01512.52
5.3.70.0070.01812.53
5.3.60.0060.01412.54
5.3.50.0030.01712.50
5.3.40.0030.02012.51
5.3.30.0050.01512.57
5.3.20.0020.01612.60
5.3.10.0050.01512.58
5.3.00.0020.02212.55
5.2.170.0030.03315.43
5.2.160.0000.04415.43
5.2.150.0030.03215.43
5.2.140.0000.03415.43
5.2.130.0000.03515.43
5.2.120.0060.02515.43
5.2.110.0030.05815.43
5.2.100.0000.03215.43
5.2.90.0000.03115.43
5.2.80.0000.03315.43
5.2.70.0040.03615.43
5.2.60.0110.02615.43
5.2.50.0040.03615.43
5.2.40.0060.02815.43
5.2.30.0000.03415.43
5.2.20.0000.04115.43
5.2.10.0060.02415.43
5.2.00.0060.02915.43
5.1.60.0000.02615.43
5.1.50.0030.02515.43
5.1.40.0030.02415.43
5.1.30.0030.02515.43
5.1.20.0070.02315.43
5.1.10.0000.02615.43
5.1.00.0000.03215.43
5.0.50.0000.02415.43
5.0.40.0030.01715.43
5.0.30.0030.02915.43
5.0.20.0000.02315.43
5.0.10.0060.01515.43
5.0.00.0000.03115.43
4.4.90.0120.00915.43
4.4.80.0030.01315.43
4.4.70.0000.01715.43
4.4.60.0030.01315.43
4.4.50.0000.01915.43
4.4.40.0070.02715.43
4.4.30.0000.02415.43
4.4.20.0000.01615.43
4.4.10.0030.01315.43
4.4.00.0030.03215.43
4.3.110.0030.01315.43
4.3.100.0030.01315.43
4.3.90.0060.01215.43
4.3.80.0030.02315.43
4.3.70.0030.01215.43
4.3.60.0000.01515.43
4.3.50.0030.01615.43
4.3.40.0000.02715.43
4.3.30.0000.01715.43
4.3.20.0000.01915.43
4.3.10.0000.01915.43
4.3.00.0000.01715.43

preferences:
45.24 ms | 401 KiB | 5 Q