var x = 25; var y = 2.5;
- Exponential values are used when you want to represent extremely large or small numbers. To write numbers in exponential form, letter e or E is used.
This represents 2.8333 raised to the power 10.
var z = 2.8333e10;
Let us see how these 64 bits are distributed to different parts of the number.
- 0 to 51st bit hold the integer or decimal value.
- 52nd to 62nd bit hold the exponential value.
- 63rd bit is dedicated for the sign, be it positive(+) or negative(-).
var variable_name = new Number(value);
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <script> var age = new Number(56); document.write('age = ', age); </script> </body> </html>
age = 56
From the execution point of view, the number objects make the execution process very slow. Hence, they are avoided.
It is the same infinity you've heard about in Mathematics. The positive infinity is displayed when the number falls above the range of floating point numbers i.e -1.797693134862315E+308 to 1.797693134862315E+308.
The most common example is 'Division by Zero' whose result is Infinity.
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <script> var num_1 = 150; var num_2 = 0; document.write( num_1 / num_2 ); </script> </body> </html>
Similar to infinity, negative infinity is displayed when a number falls below the range of floating-point numbers.
In this example, let us take a negative value as dividend.
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <script> var num_1 = -150; var num_2 = 0; document.write( num_1 / num_2 ); </script> </body> </html>
Let us see an example that shows what kind of values are NaN.
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <script> document.write(0/0); //zero divided by zero. document.write(60/'ten'); //number divided by string. </script> </body> </html>