php - Is there any particular reason that PHP doesn't do bcadd() whenever + is used?
问题描述
Whenever I'm dealing with numbers in PHP which represent money, I'm forced to use bcadd()
and the other functions in that "family", instead of simply using the nice symbols such as +
, -
, /
and *
.
The reason is something about "floats" being inaccurate for some reason. I've many times tried to understand why exactly this is, but I can't make any sense of it.
It would be much nicer to use the symbols instead of the BC Math
functions.
Why aren't the floats just accurate instead? Or made into "numerics" if "floats" by their nature are inaccurate?
It's not a problem anymore because I know about this, but for most of my life when I'm coded PHP, I had no clue even about the existence of those functions, let alone the need to use them.
解决方案
推荐阅读
- mongodb - docker-compose mongo healthcheck failing
- ios - Tableview 未正确重新加载数据,未在重新加载时呈现单元格
- react-native - React Native - 在 IOS 上单击时关闭模式
- python - 迭代两个数组以创建一系列列表
- android-studio - 是否可以将我的位置分享给另一台设备(安全)?
- contentful - 使用 Contentful Management SDK 创建资产时出错
- javascript - Shopify 部分在编辑后不运行 javascript
- hybris - Hybris UAC:具有创建员工的用户访问权限的员工无法创建员工
- angular - Angular 8:错误:(39、9)TS2304:找不到名称“*”。关闭 WebStorm 后
- java - 自定义身份验证/授权/OAuth2 响应 - Spring Security