Use 1
, not 2
.
js> 2.3 % 1
0.2999999999999998
More Related Contents:
- How do I round a number in JavaScript?
- How to deal with big numbers in javascript [duplicate]
- regular expression for finding decimal/float numbers?
- Javascript: How to retrieve the number of decimals of a *string* number?
- Why does adding two decimals in Javascript produce a wrong result? [duplicate]
- Round a float up to the next integer in javascript
- Is there a reliable way in JavaScript to obtain the number of decimal places of an arbitrary number?
- Regex in JavaScript for validating decimal numbers
- JavaScript: Round to a number of decimal places, but strip extra zeros
- round off decimal using javascript
- How to round to at most 2 decimal places, if necessary?
- Large numbers erroneously rounded in JavaScript
- Why does JavaScript handle the plus and minus operators between strings and numbers differently?
- What’s the best way to convert a number to a string in JavaScript?
- Transform numbers to words in lakh / crore system
- Check whether an input string contains a number in javascript
- Validate decimal numbers in JavaScript – IsNumeric()
- Does JavaScript support 64-bit integers?
- Add st, nd, rd and th (ordinal) suffix to a number
- How does JavaScript determine the number of digits to produce when formatting floating-point values?
- How to convert string into float in JavaScript?
- Format a number as 2.5K if a thousand or more, otherwise 900
- How can I remove the decimal part from JavaScript number?
- JavaScript displaying a float to 2 decimal places
- How can val() return Number?
- Why does a shift by 0 truncate the decimal?
- Confusion between isNaN and Number.isNaN in javascript
- 1.265 * 10000 = 126499.99999999999? [duplicate]
- Why is it that parseInt(8,3) == NaN and parseInt(16,3) == 1?
- How do you round to one decimal place in JavaScript?