Some people may say what format this is?
Actually, it's more than that.
1 //1
1.2 //1.2
1.2e3 //1200
1.2e+3 //1200
1.2e-3 //0.0012
.12e+2 //12
-.12e-2 //-0.0012
Of course these are just decimal. Let's talk about octal and hexadecimal.
0x00, 0x11, 0xff This format is hexadecimal, and their decimal values are 0, 17, 255 respectively.
01, 07, 010, 012 This is octal. (The 0 here is the number 0, not the letter o)
Some friends may have questioned it, isn't this decimal? How can it be said to be octal?
In fact, this is octal, just adding a 0 in front of the decimal.
Of course not all those who add 0 are octal.
For example, 08, 09 is actually in decimal system, because octal system is carried to 8, so it is impossible to appear 08, 09.
Do you think your vision is much broader and no longer limited to decimal expressions, and you don’t have to be afraid of being scared by the code written by Daniu.
Some friends may say, octal, hexadecimal, supports e+- format?
0x12e3 === 4835
0x12e+3 === 305
0x12e-3 === 299
0x12 === 18
Obviously, it is not the result we think about.
In fact, 0x12e3 is because e is also a character in hexadecimal. The characters in hexadecimal are 0-9 plus af, and the case doesn't matter, so 0x12e3 is a normal hexadecimal number format.
Why is 0x12e+3 not? In fact, it is just adding two numbers. The decimal system of 0x12e is 302, and adding 3 gives 305, so it is an expression, not a simple number.
The format of 011e2 is also wrong, and even reports a syntax error directly.
Therefore, the exponential format can only be used in decimal.
When you encounter 1e6 in the future, don’t naively think of it as IE6.
Don't be depressed anymore.5 Why can't it go wrong? Why does .1e1 equal 1.
Okay, today I will share this little knowledge point and think about it slowly.