11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Caché</strong> <strong>ObjectScript</strong> FunctionsWRITE !,$ISVALIDNUM(4.55,,4.54,4.551); When scale is omitted, all digits of num are checked.WRITE !,$ISVALIDNUM(4.1,0,4,4.01); When scale=0, num is rounded to an integer value; (0 decimal digits) before min & max check.WRITE !,$ISVALIDNUM(3.85,1,3.9,5); num is rounded to 1 decimal digit,; (with values of 5 or greater rounded up); before min check.WRITE !,$ISVALIDNUM(4.01,17,3,5); scale can be larger than number of decimal digits.WRITE !,$ISVALIDNUM(3.9,-1,2,3); When scale=-1, num is truncated to an integer valueNotes$ISVALIDNUM, $NORMALIZE, and $NUMBER ComparedThe $ISVALIDNUM, $NORMALIZE, and $NUMBER functions all validate numbers.$ISVALIDNUM returns a boolean value (0 or 1). $NORMALIZE and $NUMBER returna validated version of the specified number.These three functions offer different validation criteria. Select the one that best meets yourneeds.• All three 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). All three functions parse both numbers (123.45) and numeric strings (“123.45”).• Leading and trailing zeroes are stripped out by all three functions. The decimal characteris stripped out unless 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. $ISVALIDNUM rejects the string “123,456” as an invalid number.• Multiple leading signs (+ and –) are interpreted by all three functions for numbers.However, only $NORMALIZE accepts multiple leading signs in a quoted numeric string.• Trailing + and – signs: All of the three functions reject trailing signs in numbers. However,in a quoted numeric string $NUMBER parses one (and only one) trailing sign,234 <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!