11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• Rounding factor: an integer indicating how many decimal places to round to. This integercan be preceded by an optional + or - sign. If the rounding factor is positive (or unsigned)the number is rounded to the specified number of decimal digits. If the rounding factoris 0, the number is rounded to an integer. If the rounding factor is a negative integer, thenumber is rounded the indicated number of places to the left of the decimal separator.For example, a rounding factor of -2 rounds 234.45 to 200. The number “5” is alwaysrounded up; thus a rounding factor of 1 rounds 123.45 to 123.5.• Integer indicator: the letter “I” (uppercase or lowercase) which specifies that the numbermust be an integer.min and maxYou can specify a minimum allowed value, a maximum allowed value, neither, or both. Ifspecified, the num value (after rounding) must be greater than or equal to the min value, andless than or equal to the max value. A null string as a min or max value is equal to zero. If avalue does not meet these criteria, $NUMBER returns the null string.Thus in the following examples, the first is valid because num (4.0) equals max (4). Thesecond is valid because num (4.003) still equals max (4) within the format range (two decimaldigits). However, the third is not valid because $NUMBER rounds num up to a value (4.01)greater than max within the format range. It returns a null string.WRITE !,$NUMBER(4.0,2,0,4)WRITE !,$NUMBER(4.003,2,0,4)WRITE !,$NUMBER(4.006,2,0,4)You can omit parameters, retaining the commas as place holders. The first line of the followingexample sets a max value, but no format or min value. The second line sets no format value,but sets a min value of the null string, which is equivalent to zero. Thus the first line returns–7, and the second line fails the min criteria and returns the null string.SET max=10WRITE !,$NUMBER(-7,,,max)WRITE !,$NUMBER(-7,,"",max)You cannot specify trailing commas. The following results in a error:WRITE $NUMBER(mynum,,min,)$NUMBER<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 273

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!