Theme Layout

Boxed or Wide or Framed

Wide

Theme Translation

Display Featured Slider

Featured Slider Styles

Display Grid Slider

yes

Grid Slider Styles

Display Trending Posts

Display Author Bio

Display Instagram Footer

off

Dark or Light Style

Light

Blog Archive

Powered by Blogger.

Sunday, February 12, 2017

[JavaScript] Numbers


# JavaScript Numbers




● JavaScript Numbers.

 JavaScript numbers can be written with, or without decimals.
Extra large or extra small numbers can be written with exponent notation.


● JavaScript Numbers are Always 64-bit Floating Point

 Unlike many other programming languages, JSP does not define different types of numbers, like integers, short, long, floating-point etc.
JavaScript numbers are always stored as double precision floating point numbers,
following the international IEEE 754 standard.

This format stores numbers in 64 bits, where the number is stored in bits 0 to 51,
the exponent in bits 52 to 62, and the sign in bit 63.

● Precision

 Integers are considered accurate up to 15 digits.


The maximum number of decimals is 17, but floating point arithmetic is not always 100% accurate.


To solve the problem above, it helps to multiply and divide.

● Hexadecimal

 JavaScript interprets numeric constants as hexadecimal if they are preceded by 0x.


By default, JavaScript displays numbers as base 10 decimals.
But I can use the toString() method to output numbers as base 16 (hex),
base 8 (octal), or base 2(binary).

● Infinity.

 Infinity ( or -Infinity ) is the value JavaScript will return if you calculate a number outside the largest possible number.


Division by 0 (zero) also generates Infinity.


Infinity is a number. typeof Infinity returns number.

● NaN - Not a Number

 Nan is a JavaScript reserved word indicating that a number is not a legal number.
Trying to do arithmetic with a non-numeric string will result in NaN ( Not a Number).


I can use the global JavaScript function isNaN() to find out if a value is a number.


NaN is a number, and typeof NaN returns number.

● Numbers Can be Objects

 Normally JavaScript numbers are primitive values created from literals. 
  < var x = 123 >
But numbers can also be defined as objects with the keyword new.
  < var y = new Number(123) >


QuickEdit
Unknown
0 Comments
Share This Post :

You Might Also Like

No comments:

Post a Comment

Follow @SunriseSunsetBlog