Skip to main content

Numeric Literals

Numeric Literals

Numeric literals are values that ObjectScript evaluates as numbers. In contrast to string literals, they do not require a surrounding pair of delimiters. InterSystems IRIS converts numeric literals to canonical form (their simplest numeric form):

   SET x = ++0007.00
   WRITE "length:     ",$LENGTH(x),!
   WRITE "value:      ",x,!
   WRITE "equality:   ",x = 7,!
   WRITE "arithmetic: ",x + 1

You can also represent a number as a string literal delimited with quotation marks; a numeric string literal is not converted to canonical form, but can be used as a number in arithmetic operations:

   SET y = "++0007.00"
   WRITE "length:     ",$LENGTH(y),!
   WRITE "value:      ",y,!
   WRITE "equality:   ",y = 7,!
   WRITE "arithmetic: ",y + 1

For further details refer to Strings as Numbers.

ObjectScript treats as a number any value that contains the following (and no other characters):

Value Quantity
The digits 0 through 9. Any quantity, but at least one.
Sign operators: Unary Minus (-) and Unary Plus (+). Any quantity, but must precede all other characters.
The decimal_separator character (by default this is the period or decimal point character; in European locales this is the comma character). At most one.
The Letter E (used in scientific notation). At most one. Must appear between two numbers.

For further details on the use and interpretation of these characters, refer to Fundamentals of Numbers.

ObjectScript can work with the following types of numbers:

  • Integers (whole numbers such as 100, 0, or -7).

  • Fractional numbers: decimal numbers (real numbers such as 3.767) and decimal fractions (real numbers such as .0442). ObjectScript supports two internal representations of fractional numbers: standard InterSystems IRIS floating point numbers ($DECIMAL numbers) and IEEE double-precision floating point numbers ($DOUBLE numbers). For further details, refer to the $DOUBLE function.

  • Scientific notation: numbers placed in exponential notation (such as 2.8E2).

FeedbackOpens in a new tab