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 number object and give a decimal point of zero:

text = total.toFixed(0); // this generates a string 5

Number constants can be in decimal format, 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

Numbers can be used in computation using the usual operators, +, *, /, -. The increment and decrement operators (++, --) are also available in Java.

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