Javascript study notes number format types
- 2020-03-30 03:04:19
- OfStack
Some people might say what format is this?
And there's more.
1 / / 1
1.2 / / 1.2
1.2 e3 / / 1200
1.2 e+3 / / 1200
1.2 e-3 / / 0.0012
12 e + 2 / / 12
-. 12 2 / e - / - 0.0012
And of course these are just decimal Numbers. Let's talk about octal and hexadecimal.
0x00, 0x11, 0xff this format is hexadecimal, 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, this is not the decimal, how is it octal?
This is actually an octal number, just a zero before the decimal number.
< img border = 0 id = theimg onclick = window. The open this. (SRC) SRC = "/ / files.jb51.net/file_images/article/201405/201452293359581.jpg? 201442293415 ">
Of course, not all zeros are octal.
For example, 08, 09 is actually a decimal number, because octal to 8 carry, so there is no possibility of 08, 09.
< img border = 0 id = theimg onclick = window. The open this. (SRC) SRC = "/ / files.jb51.net/file_images/article/201405/201452293427365.jpg? 201442293444 ">
Don't you think you have a much broader vision, no longer limited to the decimal representation, and don't be afraid of being scared silly by the code written by Daniel.
< img border = 0 id = theimg onclick = window. The open this. (SRC) SRC = "/ / files.jb51.net/file_images/article/201405/201452293453418.jpg? 20144229357 ">
0 x12e3 = = = 4835
0 x12e + 3 = = = 305
0 x12e - 3 = = = 299
0 x12 = = = 18
Obviously, not what we thought.
Actually 0x12e3 is because e is also a hexadecimal character, the hexadecimal character is 0-9 plus a-f, case doesn't matter, so 0x12e3 is a normal hexadecimal number format.
Why isn't 0x12e+3, it's just adding two Numbers, 0x12e's decimal number is 302, add 3 to get 305, so it's an expression, not just a number.
The format of 011e2 is also wrong, or even directly reported syntax errors.
So the exponent format can only be used in the decimal system.
Later encounter 1e6 do not naive IE6.
And don't worry. Why can't 5 make a mistake? Why is.1e1 equal to 1?
Well, today to share such a small knowledge, their own slowly to ponder it.