3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Test { public function __construct(private int|float $multiplierEffect) { } public function doCalculation(int|float $input): int|float { $n = new \BcMath\Number($input); return $n->mul($this->multiplierEffect)->value; } } $test = new Test(3.4); var_dump($test->doCalculation(1.6));
Output for 8.2.31 - 8.2.33, 8.3.0 - 8.3.33, 8.5.0 - 8.5.10
Fatal error: Uncaught Error: Class "BcMath\Number" not found in /in/6goJU:8 Stack trace: #0 /in/6goJU(15): Test->doCalculation(1.6) #1 {main} thrown in /in/6goJU on line 8
Process exited with code 255.
Output for 8.4.1 - 8.4.25
Deprecated: Implicit conversion from float 1.6 to int loses precision in /in/6goJU on line 8 Deprecated: Implicit conversion from float 3.4 to int loses precision in /in/6goJU on line 10 int(3)

preferences:
43.26 ms | 798 KiB | 4 Q