An integer constant is a special case of the arithmetic constant. It's values must be integers - no decimal places.

It could be composed of several components if a constant expression is being created.

Integer constants can be defined as decimal, octal or hexadecimal values. Here are some examples:

Decimal notation -

= 150*myVariable*Hexadecimal notation -

= 0xFF*myVariable*Octal notation -

= 0377*myVariable*

With a little creativity in the scripting, you can assign string constants to the value of string objects, then decode the character value to yield an integer constant:

`myString = new String("A");`

`myVariable = myString.charCodeAt(0);`

Prev | Home | Next |

Integer arithmetic | Up | Integer promotion |

JavaScript Programmer's Reference, Cliff WoottonWrox Press (www.wrox.com)Join the Wrox JavaScript forum at p2p.wrox.comPlease report problems to support@wrox.com© 2001 Wrox Press. All Rights Reserved. Terms and conditions. |