Isn't the number of JS expressed in 64-bit floating-point numbers? Why does ES6 have the method Math.clz32 ()?

Today, when I was reading the introduction to teacher ES6 of Ruan Yifeng, I came across this Math.clz32 () method. The book says, "integers of JS are expressed in 32-bit binary form, and Math.clz32 () returns how many leading zeros there are in the form of 32-bit unsigned integers of a number."

this makes me wonder. Isn"t it true that the numbers of JS are basically expressed according to the 64-bit floating-point numbers of the IEEE754 standard? How exactly is the integer of JS expressed? I am a non-computer major, more confused, please Daniel a simple answer.

Mar.22,2021

integers (fixed-point numbers) and floating-point numbers in the computer field are just a representation of numbers, which you can understand as scientific notation, so you can also use floating-point representations to represent an integer. Don't think that floating-point numbers must be decimals.


the following is excerpted from the ES6 specification:

Math.clz32 (x):

When Math.clz32 is called with one argument x, the following steps are taken:
1. Let n be ToUint32 (x).
2. Let p be the number of leading zero bits in the 32-bit binary representation of n.
3. Return p.

that is, Math.clz32 () first converts the parameter to an unsigned 32-bit internal representation, and then returns the number of leading zeros.

Menu