Comments (5)
This is completely unrelated to TypeScript, it's just the way JavaScript works.
See also this StackOverflow question: How can I deal with floating point number precision in JavaScript?
from typescript.
ok, than please tell me the correct addition routine for typescript !
from typescript.
There's nothing to correct, this is the way floating point numbers work in JavaScript.
Did you actually check the link I posted? It provides several different approaches to this, for example rounding the number.
from typescript.
It looks like this is a question rather than a bug report. This issue tracker is for tracking bugs and active work on TypeScript itself, rather than a general forum for programmers using TypeScript to get help or ask questions.
You can ask questions on sites like Stack Overflow. We are not able to provide one-on-one support on the issue tracker. Please read the issue template carefully - it has important information on what kinds of reports can be acted on here, as well as links to useful TypeScript resources. Thanks!
from typescript.
let sum : number = 9.99;
sum += 100.12;
sum += 100.12;
console.log(sum.toFixed(2));
Try to do fixed decimal length.
from typescript.
Related Issues (20)
- TS returns an absurd type when using an inherited getter (I guess there is some kind of cache issue or something ???) HOT 1
- Inconsistency in Generic Inference for Private Properties HOT 4
- Should changing the method name from full-width characters ("fA") to half-width characters ("fA")
- 5.5.0 regression - Named exports of functions are not emitted for CommonJS HOT 4
- The inferred type of 'actions' cannot be named without a reference to '../../.yarn/__virtual__/@reduxjs-toolkit-virtual-5ff160901c/4/.yarn/berry/cache/@reduxjs-toolkit-npm-2.2.3-3fa8bcc11c-10c0.zip/node_modules/@reduxjs/toolkit/dist/entities/models'. This is likely not portable. A type annotation is necessary. HOT 4
- Different behavior between const and readonly for multidimensional array access/strict null checking HOT 7
- Rename symbol weirdness with typescript type properties
- object getters return type error HOT 12
- Poor autocomplete inside object literal as the return value of a getter HOT 1
- possibly 'undefined'. emitted after Boolean constructor check in Visual Studio HOT 2
- Error when using different types of return which should have the same result HOT 2
- [isolatedDeclarations][5.5] Disagreement between transpileDeclaration API and typechecker on Symbol.iterator as computed property HOT 7
- Handle JSDoc {@link ... } inline tags for OS
- Polymorphic this in static methods is not resolving correctly HOT 4
- Regression in detecting unused parameters in 5.5.0-beta
- Computed string literal can't be used as generic argument HOT 8
- [transpileDeclaration API] What to do about "has or is using private name" diagnostics HOT 1
- Event `type` (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement types HOT 5
- [Feat] support extending current class interface?
- TS 5.5 ConfigDir With Include Bug HOT 3
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 typescript.