SANE: Technical Product Description (2 of 2) (10/94)

  • Last Modified: October 18, 1994
  • Article: TA29374
  • Old Article: 1216


This article describes the Standard Apple Numeric Environment (SANE).

III. Choosing a Data Type:

Typically, picking a data type requires that you determine the
trade-offs between:

* fixed - or floating-point form
* precision
* range
* memory usage
* speed

The precision, range, and memory usage for each SANE data type are shown in the table of SANE types below. Effects of the data types on performance (speed) vary among the implementations of SANE.

Most accounting applications require a counting type that counts things (pennies, dollars, widgets) exactly. Accounting applications can be implemented by representing money values as integrel numbers of cents or mils, which can be stored exactly in the storage format of the COMP (for computational) type. The sum, difference, or product of any two comp values is exact if the magnitude of the result does not exceed 2^63 - 1 (that is, 223,372,036,854,775,807). This number is larger than the U.S national debt expressed in Argentine pesos. In addition, comp values (such as the results of accounting computations) can be mixed with extended values in floating-point compitations (such as compound interest).

Arithmetic with comp-type variables, like all SANE arithmetic, is done internally using extended-precision arithmetic. There is no loss of precision, as converson from comp to extended is always exact. Space can be saved by storing numbers in the comp type, which is 20 percent shorter than extended. Non-accounting applications will normally be better served by floating-point data formats.

IV. Values Represented:

The floating-point storage formats (single, double and extended) provide binary encodings of a SIGN (+ or -), an EXPONENT, and a SIGNIFICAND. A represented number has the value

+/-significand = 2 exponent

where the significand has a single bit to the left of the binary point (that is, O <- significand < 2).

V. Range and Precision of SANE Types:

The table below describes the range and precision of the numeric data types supported by SANE. Decimal ranges are expressed as chopped two-digit decimal representations of the exact binary values.

SANE DATA TYPES

TYPE CLASS APPLICATION ARITHMETIC

Type Identifier Single Double Comp Extended

Size (bytes:bits) 4:32 8:64 8:64 10:80

Binary exponent
range
Minimum -126 -1022 --- -16383
Maximum 127 1023 --- 16383

Significand precision
Bits 24 53 63 64
Decimal digits 7-8 15-16 18-19 19-20

Decimal range
(approximate)
Min negative -3.4E+38 -1.7E+308 9.2E18 -1.1E+4932
Max neg norm -1.2E-38 -2.3E-308 -1.7E-4932
Max neg denorm -1.5E-45 -5.0E-324 -1.9E-4591

Min pos denorm 1.5E-45 5.0E-324 1.9E-4951
Min pos norm 1.2E-38 2.3E-308 1.7E-4932
Max positive 3.4E+38 1.7E+308 9.2E18 1.1E+4932

Infinitive Yes Yes No Yes

NaNs Yes Yes Yes Yes

Usually numbers are stored in a normalized form, to afford maximum precision for a given significan width. Maximum precision is acheived if the high order bit in thr significand is 1 (that is, 1</- significand < 2).


Article Change History:
18 Oct 1994 - Reviewed for technical accuracy, revised formatting.

Support Information Services
Not helpful Somewhat helpful Helpful Very helpful Solved my problem