1 digit
Numbers are one of the basic data types in javascript. javascript does not distinguish integer and floating-point values. Javascript uses the 64-bit floating format defined in the IEEE 754 standard, basically similar to the double type in Java.
Javascript supports direct numeric values: integer values, octal and hexadecimal values, and floating point values.
2. Number object
Number object, which is the packaging object of the original value. When necessary, JavaScript will automatically convert between the original data and the object.
The constructor Number () can be used directly as a conversion function instead of the new operator. When you call Number () in this way, it will convert its parameter into a Number, and then return the converted original value (or NaN ). Constructors are usually used as placeholders for five useful numeric constants, these five useful numeric constants are the maximum number that can be expressed, the minimum number that can be expressed, positive infinity, negative infinity, and special NaN values. Similar to the static member attribute in c #, it cannot be instantiated.
Number. MAX_VALUE |
The maximum number that can be expressed. |
Number. MIN_VALUE |
The smallest number that can be expressed. |
Number. NAN |
Special Non-numeric value |
Number. POSITIVE_INFINITY |
Special Value indicating positive infinity |
Number. NEGATIVE_INFINITY |
Special Value of negative infinity |
There are two special value constants Infinity and NaN, representing Infinity and non-numbers, respectively.
NaN! = NaN
Infinity = Infinity
Number. POSITIVE_INFINITY: Infinity
Number. NEGATIVE_INFINITY:-Infinity
Two special functions are used to determine special values.
IsNaN () |
Check special value NaN. NaN! = NaN, but isNaN (NaN) = true; |
IsFinite () |
Checks whether a number is NaN, positive, or negative. |
An issue with isNaN (): it implicitly converts its parameter to a number, so even if the parameter is a string that cannot be converted to a number, it will also return true (converted to NaN), so it does not use the type detection to directly judge, the following version can solve the problem:
Number. isNaN = function (value ){
Return typeof value = 'number' & isNaN (value );
};
Three-digit calculation
Use the Arithmetic Operators (+,-, *,/, etc.) or use the functions of the Math object for calculation.
References are as follows (if there is any infringement, please contact me in time ):
Javascript authoritative guide (fifth edition)
Http://www.w3school.com.cn/js/pro_js_referencetypes.asp
Http://www.cnblogs.com/ziyunfei/archive/2012/09/19/2690866.html