In your followup post, I see that I misunderstood your reference to currency.
Let's not confuse the intended use with the data type as I did. Excel doesn't
list data types the way a programmer would. It is intended for the layperson to
use. Thus, "currency" describes one use of a scaled integer type that has a
fixed radix point with 4 digits to the right of the radix. I suppose it isn't
much use for other applications. The integer nature of the type and the
simplicity of operators in financial calculations makes it a good type for
finance. Integer math is fast. The programmer does not have to be that strong
in numeric methods.

The single and double reals are IEEE 754 short and long floating point reals.
Good from a coder's POV, since the internal FPU of any CPU from the 486DX
onwards will handle calculations in hardware automatically. Very quick
performance for the user and easy for the programmer. Most compilers support
these types. As you pointed out, range can be a problem with the short real.
Rounding error is a problem in them due to their floating point nature. These
types are in some ways artifacts of the way things were. Backwards
compatibility and the inertia of "this is how we've always done it" may be
factors, too. The best technical solution does not always win.

The long integer type is OK if you are willing to do your own scaling. Embedded
folks have done this for ages because an FPU was a rarity in most work. Some,
like Forth devotees, take reliance on integer math to an extreme, having fought
over whether to include FP in the Forth ANSI spec at all.

If the data types don't fit your application, I suppose that you have a valid
complaint. Excel has a pedestrian set of data types meant for general purpose
work. For work with minimum roundoff issues on large or small numbers, it would
have a bcd library capable of lots of precision or a string-based library
though I consider string-based math to be a bit of a kludge. The data storage
requirements would go way up, but today's machines have the resources to go
this route.

One problem with a mix of data types is what to do in mixed mode operations.
Precise operands can be compromised by an imprecise operand to yield an
imprecise result.

If folks do not choose the data type properly, their results may be less
precise than they otherwise could have been.


--
David Firth

Still Thinking Different: Apple Powerbook 3400 & Newton 2100




=================================================================
Instructions for joining and leaving this list, remarks about the
problem of INAPPROPRIATE MESSAGES, and archives are available at
                  http://jse.stat.ncsu.edu/
=================================================================

Reply via email to