Comments (1)
Congratulations, you've discovered floating-point arithmetic! Yes, sometimes doing math with non-integer numbers produces values that are slightly different than what you may expect. No, this is not a bug with PHP but actually a common issue with virtually every programming language.
Check that your precision
and/or serialize_precision
settings are set to -1 - or at least are set to reasonable values according to your needs. You also can round
your results to an appropriate number of decimal places, remembering to do that only at the end of your calculations and never in the middle of them. Finally, if neither of those solutions works for you because of some very specific and unusual circumstances, arbitrary-precision math using BC or GMP is available.
edited with improved copypasta
from php-src.
Related Issues (20)
- Fallback to using Certificate Authority from Windows Certificate Store HOT 1
- socket_getsockname returns wrong address on some unix filename
- "gmake test" fails with 98.5% HOT 7
- Regression: Values on array properties on $this are not available to anonymous function are they have mutated HOT 4
- Dump wrapped object in `WeakReference` class HOT 1
- Corrupted memory in destructor with weak references HOT 10
- `hash_update` returns always `true` HOT 4
- Failing openssl_private_decrypt tests
- ext/mysqli/tests/bug34810.phpt test failing with mariadb-11.4 HOT 4
- Segmentation fault when get notationName of unparsed DOMEntity HOT 2
- [FEATURE REQUEST] _array_walk_recursive with path and reference processing HOT 1
- `HTMLDocument::saveHTML` returns `$node`’s inner HTML rather than outer HTML HOT 3
- Change the way built-in functions are resolved HOT 2
- fopen creates files with utf characters under certain conditions HOT 8
- Segmentation fault under high loads in openssl_encrypt in ZTS build (FrankenPHP) HOT 9
- Object dependency without inheritance HOT 1
- Adding support for gmp_prevprime
- GC does not scale well with a lot of objects created in destructor HOT 3
- Test failed with leaked memory HOT 1
- Build system installs libtool wrappers when using slibtool HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-src.