Comments (2)
Summary: The toStringAsFixed(2)
method and NumberFormat.decimalPatternDigits
in Flutter fail to round numbers ending in 5 correctly, producing inconsistent results across different inputs. For example, 5.505 rounds to 5.50 instead of 5.51.
from sdk.
That's how floating point numbers actually work. Floating point 5.505
is not the same as decimal number 5.505
, so it absolutely correctly rounds to 5.5
if you ask less decimal digits.
I recommend:
- Learning how floating point numbers work: https://floating-point-gui.de/
- Never using floating point numbers for anything that requires correct decimal rounding (e.g. storing prices and monetary amounts).
from sdk.
Related Issues (20)
- Failures on [dart2wasm] Use unsafeCast in a few places...Reland "[vm] Move `ResolveUri` to bin" HOT 3
- Analyzer data-based fix request HOT 2
- `dart compile js` fails with the newest SDK HOT 17
- Cannot resolve top-level methods with docimports HOT 4
- [Wildcard Variables] Update `DUPLICATE_DEFINTION` reporting
- CFE fails to report error when `super` is used in a redirecting constructor. HOT 2
- DevTools not serving properly on app refresh HOT 1
- [Wildcard Variables] Update `DUPLICATE_FIELD_FORMAL_PARAMETER` reporting
- `@internal` annotation does not supress `public_member_api_docs` lint on functions HOT 1
- Dart analyzer does not infer the correct type for generic record HOT 2
- Having true cancelable future HOT 2
- Simplify branch conditions based on ranges & simplify control flow afterwards if condition turns out to be constant
- Issue in number multiplication with 10, 20, etc HOT 4
- Feature Request: Add `--insert-ignore-comments` flag to `dart fix` command for existing code HOT 3
- [vm/core] `_GrowableList.add` has unnecessary bounds check
- docImports failing to allow for resolution in some flutter animation library code HOT 4
- Implement augmentations HOT 6
- Support macros when analyzer is used as a library HOT 1
- Is that possible to set breakpoints in the macro code itself? HOT 2
- Inability to Convert Dart BigInt to JSBigInt using new js_interop HOT 1
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 sdk.