In addition to regular numeric values, RWDecimal and RWFixedDecimal classes can also take on one of three special non-numeric values: null, missing, or NaN. The null and missing values are useful because of their properties when used in calculations. In most cases, an arithmetic operation involving a number and null will result in the numeric operand. Using null allows the representation of a non-numeric value without propagating that value throughout the calculations. A missing value is different in that it will propagate through calculations; an arithmetic operation involving a missing value will have a missing value as a result. The NaN value is primarily an error value, For example, an NaN value will result from division by zero. The following list describes how these values operate when used in calculations. (The value 2 could be any numeric value.)
2 + (null) = 2 (null) + 2 = 2 2 + (missing) = (missing) (missing) + 2 = (missing) 2 + (NaN) = (NaN) (NaN) + 2 = (NaN) (null) + (missing) = (missing) (missing) + (null) = (missing) (null) + (NaN) = (NaN) (NaN) + (null) = (NaN) (missing) + (NaN) = (missing) (NaN) + (missing) = (missing) 2 - (null) = 2 (null) - 2 = -2 2 - (missing) = (missing) (missing) - 2 = (missing) 2 - (NaN) = (NaN) (NaN) - 2 = (NaN) (null) - (missing) = (missing) (missing) - (null) = (missing) (null) - (NaN) = (NaN) (NaN) - (null) = (NaN) (missing) - (NaN) = (missing) (NaN) - (missing) = (missing) 2 * (null) = 2 (null) * 2 = 2 2 * (missing) = (missing) (missing) * 2 = (missing) 2 * (NaN) = (NaN) (NaN) * 2 = (NaN) (null) * (missing) = (missing) (missing) * (null) = (missing) (null) * (NaN) = (NaN) (NaN) * (null) = (NaN) (missing) * (NaN) = (missing) (NaN) * (missing) = (missing) 2 / (null) = 2 (null) / 2 = (NaN) 2 / (missing) = (missing) (missing) / 2 = (missing) 2 / (NaN) = (NaN) (NaN) / 2 = (NaN) (null) / (missing) = (missing) (missing) / (null) = (missing) (null) / (NaN) = (NaN) (NaN) / (null) = (NaN) (missing) / (NaN) = (missing) (NaN) / (missing) = (missing)
Each RWDecimal<T> class has static members null, missing, and NaN that can be used to assign or test for these values. For example
RWDecimal<RWMP2Int> a = RWDecimal<RWMP2Int>::missing; RWDecimal<RWMP2Int> b; . . . if(b == RWDecimal<RWMP2Int>::NaN) printError();
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.