How to useMathematical Operation in Javascript
In this approach, we are using the mathematical operation of printing the JavaScript’s highest integer value that a number can go to without losing precision. Here we have used the operation 2 ** 53 – 1 to generate the highest integer value.
Syntax:
return 2 ** 53 - 1
Example: This example implements the above-mentioned approach
Javascript
const maxInteger = () => { return 2 ** 53 - 1; }; console.log( `Max Safe Integer is: ${maxInteger()}` ); |
Output
Max Safe Integer is: 9007199254740991
What is JavaScript’s highest integer value that a Number can go to without losing precision?
In this article, we are going to implement a JavaScript program that will return the highest integer value that the number can go to without losing precision.
Below are the three approaches using which we will get the highest integer value without losing precision
Table of Content
- Using Number.MAX_SAFE_INTEGER Constant
- Using Mathematical Operation
- Using user-defined Function
Contact Us