11 JavaScript Number Objects & scientific notation binary conversion & & & range overflow Infinity & NaN

JavaScript Number Object

  • The object is able to handle the digital value of the wrapped
  • () Constructor creates a Number
  • Only one type of digital
  • You may or may not use decimal numbers written

 

Digital property:

  • MAX_VALUE
  • MIN_VALUE
  • NEGATIVE_INFINITY
  • POSITIVE_INFINITY
  • NaN
  • prototype
  • constructor

 

Digital methods:

  • toExponential () is converted into exponential notation
  • toFixed () rounding, as toFixed (2), rounded to 2 decimal places
  • toPrecision () converts a value specified length
  • toString()
  • valueOf()

 

 

Scientific notation:

var y = 123e5 = 12300000;

was z = 123e-5 = 0.00123;

 

All figures are 64 JavaScript

JavaScript is not the type of language, does not define different types of digital, such as integer, short, long, float, and so on.

JavaScript All numbers are 64-bit floating point type, a maximum of ± 1.7976931348623157 x 10308, the minimum value of ± 5 x 10 -324. (Bits i.e. bits 0 and 1)

 

JavaScript hex conversion:

  • number.toString (16); an output 16
  • number.toString (8); Output 8
  • number.toString (2); Output 2
<script type="text/javascript" charset="utf-8">
    var x = 128;
    document.write(x+" 十进制</br>");
    document.write(x.toString(16)+" 十六进制</br>");
    document.write(x.toString(8)+" 八进制</br>");
    document.write(x.toString(2)+" 二进制</br>");
</script>

Infinity ( Infinity )

  • When the digital calculation result exceeds the upper limit number (overflow) can be represented in JavaScript, as a result of an infinite value, expressed in JavaScript to Infinity.
  • When the negative value of the overflow, the result is negative infinity to -Infinity expressed. Infinity is infinity operation reserved symbols.
  • In addition to 0 it is infinite, signed.

 

NAN non-numeric values

  • Determines whether or not a general digital isNaN ().
  • In JavaScript, if the value can not be converted to digital, then return NaN.
  • In JavaScript, it may be a digital value or an object.

 

Guess you like

Origin www.cnblogs.com/ltfxy/p/11627864.html