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.

<strong>Caché</strong> <strong>ObjectScript</strong> FunctionsWRITE !,$NORMALIZE(4.55,2); When scale is equal to the decimal digits of num,; all digits of num are returned without rounding.WRITE !,$NORMALIZE(3.85,1); num is rounded to 1 decimal digit,; (with values of 5 or greater rounded up); here 3.9 is returned.WRITE !,$NORMALIZE(4.01,17); scale can be larger than number of decimal digits,; and no rounding is peformed; here 4.01 is returned.WRITE !,$NORMALIZE(3.85,0); When scale=0, num is rounded to an integer value.; here 4 is returned.WRITE !,$NORMALIZE(3.85,-1); When scale=-1, num is truncated to an integer value.; here 3 is returned.Notes$NORMALIZE, and $NUMBER ComparedThe $NORMALIZE, and $NUMBER functions both validate numbers and return a validatedversion of the specified number.These two functions offer different validation criteria. Select the one that best meets yourneeds.• Both functions parse signed and unsigned integers (including –0), exponential numbers(with “E” or “e”), and decimal numbers. However, $NUMBER can be set (using the “I”format) to reject decimal numbers (including negative exponents that result in decimalnumbers). Both functions parse both numbers (123.45) and numeric strings (“123.45”).• Both functions strip out leading and trailing zeroes. The decimal character is stripped outunless followed by a non-zero value.• Numeric strings containing a NumericGroupSeparator: $NUMBER parses Numeric-GroupSeparator characters (American format: comma (,); European format: period (.) orapostrophe (')) and the decimal character (American format: period (.) or European format:comma (,)) based on its format parameter (or the default for the current locale). It acceptsand strips out any number of NumericGroupSeparator characters. For example, inAmerican format it validate “123,,4,56.99” as the number 123456.99. $NORMALIZEdoes not recognize NumericGroupSeparator characters. It validates character-by-characteruntil it encounters a non-numeric character; for example, it validates “123,456.99” as thenumber 123.• Multiple leading signs (+ and –) are interpreted by both functions for numbers. Only$NORMALIZE accepts multiple leading signs in a quoted numeric string.270 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!