Difference between revisions of "INF, Nan, Zero and IEEE/SANE arithmetic"

(MH Rewrite)
Line 1: Line 1:
The IEEE 754 standard for floating point arithmetic (related to a standard called SANE), specifies a standard for finite-precision floating point arithmetic.
+
Analytica 4.0 complies with the ''IEEE 754 standard'' (and the related ''SANE standard'') for floating point arithmetic, including in its treatment of infinite values. As specified by IEEE 754, Analytica represents three special values:
 +
: INF: Infinity
 +
: -INF: negative infinity
 +
: NaN: Not a Number
  
''Analytica 4.0 complies with IEEE 754 (and SANE).  Note that Analytica 3.1 and earlier differed from this standard when multiplying by zero.  If you have a legacy 3.1 model that relies on multiplication by zero to zero out INFs or NaNs, you will discover that downstream results are NaN in in Analytica 4.0.''
+
Analytica follows IEEE 754 and SANE standards in the following:
  
To detect this situation, keep the "Show Result Warnings" preference on. A warning is displayed in Analytica 4.0 if you multiply INF or NaN by zero.
+
:x * INF → INF for x>0
 +
:x * -INF &rarr; INF for x<0
 +
:INF - INF &rarr; NaN
 +
:x / 0 &rarr; INF for x>0
 +
:0 * INF &rarr; NaN
 +
:0 / 0 &rarr; NaN
 +
:x * NaN &rarr; NaN
  
Under IEEE 754 and in Analytica, there are three special values: INF, -INF, and NaN, representing infinity, negative infinity and "Not a Number". The IEEE 754 and SANE standards specify the desired results of arithmetic operations involving these values.  For example:
+
Note: x>0 means x is not NaN but may be INF.
  
x / 0 = INF for x>0
+
In this, Analytica 4.0 differs from 3.1 and earlier releases which did not comply with the IEEE 754 standard when multiplying INF or Nan by zero. Analytica 3.1 and earlier gave:
0 / 0 = NaN
+
:0 * INF &rarr; 0
x * INF = INF for x>0
+
:0 * NaN &rarr; 0
0 * INF = NaN
 
INF - INF = NaN
 
x * NaN = NaN
 
 
 
Note: x>0 means x is not NaN but may be INF.
 
  
In Analytica 3.1 and earlier, 0*x resulted in 0 for any x, even x=NaN or x=INF.
+
If you find that your model built with Analytica 3.1 or earlier is now generating NaN, where before it generated numbers, this change could be the reason.  Analytica 4.0 will give a warning if it detects such a multiplication of INF or NaN by zero, if you check '''Show Result Warnings''' in the '''Preferences''' dialog from the '''Edit''' menu.  on.  
  
To determine whether x is Nan, use the IsNaN(x) function.  To determine whether x is INF or -INF, use the comparison x=INF or x=-INF.  The IsNumber(x) function returns true for x=INF, x=-INF and x=NaN (but false for text strings, references, null, etc).
+
You can test whether x is Nan or INF in these ways:
 +
: x=INF
 +
: x=-INF
 +
: IsNan(x) &rarr; True (1) if x=Nan
 +
: IsNumber(x) &rarr; True (1) if x is a number, INF, -INF, or Nan, and False (0) if x is a text, reference, Null, Undefined, or other type.

Revision as of 17:50, 6 February 2007

Analytica 4.0 complies with the IEEE 754 standard (and the related SANE standard) for floating point arithmetic, including in its treatment of infinite values. As specified by IEEE 754, Analytica represents three special values:

INF: Infinity
-INF: negative infinity
NaN: Not a Number

Analytica follows IEEE 754 and SANE standards in the following:

x * INF → INF for x>0
x * -INF → INF for x<0
INF - INF → NaN
x / 0 → INF for x>0
0 * INF → NaN
0 / 0 → NaN
x * NaN → NaN

Note: x>0 means x is not NaN but may be INF.

In this, Analytica 4.0 differs from 3.1 and earlier releases which did not comply with the IEEE 754 standard when multiplying INF or Nan by zero. Analytica 3.1 and earlier gave:

0 * INF → 0
0 * NaN → 0

If you find that your model built with Analytica 3.1 or earlier is now generating NaN, where before it generated numbers, this change could be the reason. Analytica 4.0 will give a warning if it detects such a multiplication of INF or NaN by zero, if you check Show Result Warnings in the Preferences dialog from the Edit menu. on.

You can test whether x is Nan or INF in these ways:

x=INF
x=-INF
IsNan(x) → True (1) if x=Nan
IsNumber(x) → True (1) if x is a number, INF, -INF, or Nan, and False (0) if x is a text, reference, Null, Undefined, or other type.
Comments


You are not allowed to post comments.