Number Type

JavaScript does not have an integer type and a float type. All numbers are treated as float by default.

var total = 2 + 3;

text = total; // this will convert the number to 5.0

To force a number to be treated as an integer, use the toFixed() method of the number object and give a decimal point of zero:

text = total.toFixed(0); // generates the string “5”

A number constant is in decimal format by default, hexadecimal format if it starts with '0x', and octal format if it starts with '0'.

decimal_number = 255 // -- Decimal is the default

hex_number = 0xff

fp_number = 2.456 // -- Floating point number

Numerical computations are performed with the usual operators, +, *, /, -. The increment and decrement operators (++, --–) are also available.

<< Object Types and Scopes © 1996-2013 InetSoft Technology Corporation (v11.5) Boolean Type >>