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.

Because numbers generated by $DOUBLE are rounded, equality comparisons should not beattempted between $DOUBLE values and standard <strong>Caché</strong> decimal point number values.The ZZDUMP command returns a different datatype value for list items that were generatedusing $DOUBLE.The <strong>Caché</strong> SQL data types DOUBLE and DOUBLE PRECISION represent IEEE floatingpoint numbers; the FLOAT data type represents standard <strong>Caché</strong> decimal point numbers.INF and NANFollowing the IEEE standard, $DOUBLE can return the strings INF (infinity) and NAN (nota number). While these are valid IEEE return values, they are not actual numbers. Therefore,the $ISVALIDNUM function returns a 0 for these values.$DOUBLE returns an INF value (or a -INF for negative numbers) when the numeric valueexceeds the available precision, as shown in the following example:SET x=$DOUBLE(1.2e300)WRITE !,"Double: ",xWRITE !,"Is number? ",$ISVALIDNUM(x)SET y= $DOUBLE(x*x)WRITE !,"Double squared: ",yWRITE !,"Is number? ",$ISVALIDNUM(y)$DOUBLE returns a NAN (not a number) value when the numeric value is invalid. Forexample, when an arithmetic expression involves two INF values, as shown in the followingexample. (An arithmetic expression involving a single INF value returns INF.)SET x=$DOUBLE(1.2e500)WRITE !,"Double: ",xWRITE !,"Is number? ",$ISVALIDNUM(x)SET y= $DOUBLE(x-x)WRITE !,"Double INF minus INF: ",yWRITE !,"Is number? ",$ISVALIDNUM(y)Integer DivideWith certain values, <strong>Caché</strong> floating point and IEEE double numbers yield a different integerdivide product. For example:WRITE !,"Divide operations:"WRITE !,"Cache /: ",4.1/.01 // 410WRITE !,"Double /: ",$DOUBLE(4.1)/.01 // 410WRITE !,"Integer divide operations:"WRITE !,"Cache \: ",4.1\.01 // 410WRITE !,"Double \: ",$DOUBLE(4.1)\.01 // 409ExamplesThe following example returns floating point numbers of 15 digits:$DOUBLE<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 201

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

Saved successfully!

Ooh no, something went wrong!