mastodonien.de

phpc.social

Zeitpunkt              Nutzer    Delta   Tröts        TNR     Titel                     Version  maxTL
Mi 02.10.2024 00:02:59     4.806      +4      281.871    58,6 PHP Community on Mastodon 4.2.13     500
Di 01.10.2024 00:01:17     4.802      +6      281.562    58,6 PHP Community on Mastodon 4.2.13     500
Mo 30.09.2024 00:01:15     4.796       0      281.164    58,6 PHP Community on Mastodon 4.2.12     500
So 29.09.2024 00:01:25     4.796      +1      280.940    58,6 PHP Community on Mastodon 4.2.12     500
Sa 28.09.2024 00:01:10     4.795      +1      280.625    58,5 PHP Community on Mastodon 4.2.12     500
Fr 27.09.2024 00:01:19     4.794      +1      280.300    58,5 PHP Community on Mastodon 4.2.12     500
Do 26.09.2024 00:00:30     4.793       0      279.972    58,4 PHP Community on Mastodon 4.2.12     500
Mi 25.09.2024 00:01:08     4.793      +2      279.604    58,3 PHP Community on Mastodon 4.2.12     500
Di 24.09.2024 00:00:05     4.791      +3      279.288    58,3 PHP Community on Mastodon 4.2.12     500
Mo 23.09.2024 00:00:10     4.788       0      278.929    58,3 PHP Community on Mastodon 4.2.12     500

Mi 02.10.2024 22:27

oh I like this new BCMath Number extension and its operator overloading !!!!!

And real question...
Would this be a first step towards full support for operator overloading ?
Cuz the text says:
« The new BCMath\Number class supports operator overloading, which cannot be done by userland PHP classes __yet__,»

See ? __yet__
Meaning it will... soon ?

anyways thanks a lot @saki !!!

thephp.foundation/blog/2024/10

screenshot from https://thephp.foundation/blog/2024/10/02/php-core-roundup-19/ showing the new BCMath Number class
scrrenshots show the following text:

BCMath extension getting Number class and new functions

The BCMath extension in PHP 8.4 now has classes with support for operator overloading support!

use BCMath\Number;  

$num1 = new Number('22');  
$num2 = new Number('7'); 
$num3 = new Number('100');

$result = ($num1 / $num2) + $num1 - $num2;
echo $result; // 18.1428571428

Now, instead of using BCMath functions such as bcadd, bcsub, bcdiv, etc, you can now simply use standard operators (+, -, /, etc.).

The new BCMath\Number class supports operator overloading, which cannot be done by userland PHP classes yet, but the BCMath extension implements it, so you can use them as if they were regular numbers.

The BCMath\Number class implements Stringable interface, so the objects can be used where a string is expected (like how the example above uses it with an echo call). Further, the class implements all bc* functions. For example, it's also possible to call $num->add($num2) or $num->add('5') and it returns a new BCMath\Number object without modifying the original object, which makes them immutable.

This comes from Saki Takamachi 💜, one of our new PHP Foundation members. She also made several new improvements including adding new bcfloor, bcceil, bcround, and bcdivmod functions.

screenshot from https://thephp.foundation/blog/2024/10/02/php-core-roundup-19/ showing the new BCMath Number class scrrenshots show the following text: BCMath extension getting Number class and new functions The BCMath extension in PHP 8.4 now has classes with support for operator overloading support! use BCMath\Number; $num1 = new Number('22'); $num2 = new Number('7'); $num3 = new Number('100'); $result = ($num1 / $num2) + $num1 - $num2; echo $result; // 18.1428571428 Now, instead of using BCMath functions such as bcadd, bcsub, bcdiv, etc, you can now simply use standard operators (+, -, /, etc.). The new BCMath\Number class supports operator overloading, which cannot be done by userland PHP classes yet, but the BCMath extension implements it, so you can use them as if they were regular numbers. The BCMath\Number class implements Stringable interface, so the objects can be used where a string is expected (like how the example above uses it with an echo call). Further, the class implements all bc* functions. For example, it's also possible to call $num->add($num2) or $num->add('5') and it returns a new BCMath\Number object without modifying the original object, which makes them immutable. This comes from Saki Takamachi 💜, one of our new PHP Foundation members. She also made several new improvements including adding new bcfloor, bcceil, bcround, and bcdivmod functions.

[Öffentlich] Antw.: 0 Wtrl.: 2 Fav.: 0

Antw. · Weiterl. · Fav. · Lesez. · Pin · Stumm · Löschen