As a user, I want to have native decimal scalar type support. And at
the same time:
1) Use a native numeric variable type compatible with other numeric
types without typecasts: 1 + 0.5 (int + decimal).
2) Do not use BCMath that uses strings. In PHP8, passing float values
to BCMath may lead to issues due to type mismatch which is a
mind-blowing counter-intuitive issue. It looks like a band-aid over
the missing functionality. Programming with BCMath is weird.
3) Avoid installing any 3-rd party extensions.
4) Available on any PHP distribution by default, including commercial
hostings where I can not install additional extensions.

Why:
1) Decimal is the most intuitive type for decimal calculations.
2) Decimal doesn't have hidden unintuitive unexpected drawbacks like
float has: (0.1 + 0.2 - 0.3) != 0 which will help improve the overall
code quality by decreasing the room for errors.
3) A lot of applications work with money, weights, and dimensions,
where users need to have proper calculations.
4) A lot of applications work with MySQL and other database engines
which support the decimal column type. With PHP decimal support,
calculations and storage will be seamless.
5) Native decimal calculations are significantly faster than BCMath
which converts to and from strings.
6) I personally think that the native decimal type support is a
"must-have" for a mature programming language.

Ideal solution:
A `decimal` builtin scalar type with some predefined precision
(probably configured in php.ini). I can set the precision explicitly
like `decimal(10,4)`.

Good solution:
Make the php-decimal PEAR extension built-in and available by default.

I was told that this mailing list is a proper place for this kind of
proposal. Hope it helps to improve my favorite programming language :)
Who should add an RFC if the proposal will be accepted by the
community?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to