Value of type number: integer/floating point value
Integer
decimal e.g.: var intnum = 50;
Octal (Invalid in strict mode, parse error) The first word value must be 0, followed by a sequence of numbers of 0~7 e.g.: var intnum = 070; resolves to decimal 56 (if the literal value is out of range, the leading 0 is ignored and the subsequent value is parsed as a decimal value e.g.: var intnum = 078;//Invalid octal number, parsed to decimal 78)
The first two digits of the hexadecimal literal must be 0x (or 0X), followed by a sequence of 0~7 or a~f (uppercase or lowercase) e.g.:var intnum = 0xA; Parse to decimal 10
When arithmetic is calculated, all values in eight hexadecimal and hex are eventually converted to decimal numerical calculations.
Floating point number
The numeric value must contain a decimal point, and must have at least one digit e.g after the decimal.: var floatnum = 1.5; (There can be no integer before the decimal point, e.g.: var floatnum =. 5; Valid, resolves to 0.5, but not recommended)
If there is no number after the decimal point, it will be resolved to integer value e.g.: var floatnum = 5.; Resolves to an integer 5 (because the memory space required for floating-point numbers is twice times the number of integers saved, ECMAScript will lose no chance to convert floating-point values to integer values)
Scientific notation the maximum or minimum value can be expressed by E (or E), which is equal to the value in front of e multiplied by the exponential power of 10.
Range of values
Maximum value: Number.MAX_VALUE 1.7976931348623157e+308
Minimum value: Number.min_value 5e-324
Exceeding the maximum value, automatic conversion to infinity/-infinity Infinity value cannot participate in the calculation (Number.positive_infinity/number.negative_infinity also holds infinity/- Infinity)
Determines whether there is a poor value isfinite (ARG) arg can be any type of data, non-number data is implicitly converted to Number data
NaN
A non-numeric value (not a number) holds a data that would otherwise return a numeric value but does not return a value such as any number divided by 0, which returns Nan
Any operation with Nan will return a Nan
Nan and any value do not want to wait, including Nan itself
Determines whether the Nan IsNaN (ARG) arg can be any type of data, and non-number data is implicitly converted to Number data
numeric conversions
Number ()/parseint ()/parsefloat ()
Number () can be used to convert any data type to numeric parseint ()/parsefloat () is typically used to convert a string into a numeric value
Number () Conversion rule:
Boolean true-->1 false-->0
Number returns itself
Null 0
Undefined NaN
String A/contains only numbers (including the front with the right or the symbol)--decimal value (ignoring 0 with leading 0, does not convert to octal/preamble to 0x, hexadecimal size decimal)
b/contains only floating-point value----the corresponding floating-point number (leading 0 is ignored)
c/contains only empty strings-->0
D/contains other characters-->nan
parseint () conversion rules: (because number () handles string conversions too complex, general string conversions are better with parseint ())
Mainly see if it conforms to the numerical model
Ignores whitespace in front of the string until the first non-whitespace character is found
A/The first character is not a number or a sign-->nan e.g.:p arseint ("ABCD")-->nan e.g.:p arseint ("")-->nan (Difference numbers ("")-->0)
The first character is a numeric character, sequentially parsing the second, until all characters have been resolved, or when a non-numeric character has been encountered, and the number literal e.g has been successfully resolved to a number.:p arseint ("1234blue")-->1234
C/can parse various formats for integer numbers of type number: decimal/Eight binary/16 binary (parseint () can pass the second parameter: How much, hexadecimal can be passed without the front 0x, the recommended way to pass with two parameters) e.g.:p arseint ("0xA")-- >10 parseint ("A", +)-->10
Parsefloat () Conversion rules:
Similar to parseint ()
When there are more than two decimal points in a character, the first decimal point is valid, the second one is invalid, and the following characters are ignored e.g.:p arsefloat ("11.22.33")-->11.22
Only the decimal format string is parsed, and no second parameter specifies the conversion mode
The hexadecimal format string-->0 e.g.:p arsefloat ("0xA")-->0
Integer string with no decimal point--integer e.g.:p arsefloat ("1234blue")-->1234
Scientific counting method e.g.:p arsefloat ("3.14e2")-->314
[javascript| basic concept |number] learning notes