Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!news.mathworks.com!fu-berlin.de!golden-gate.owl.de!uni-paderborn.de!news.rwth-aachen.de!genesis.westend.com!news.gtn.com!blackbush.xlink.net!ins.net!heeg.de!hmm
From: hmm@heeg.de (Hans-Martin Mosner)
Subject: Re: Smalltalk Float Class
Message-ID: <Dx5sD0.2L0@heeg.de>
Sender: uucp@heeg.de
Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
X-Newsreader: TIN [version 1.2 PL2]
References: <321CF0A4.6A00@magic.fr> <321DB615.699A@dexinfo.com> <tvd909dycr.fsf@betze.bbn.hp.com>
Date: Tue, 3 Sep 1996 13:34:11 GMT
Lines: 44

Kohler Markus (kohlerm@betze.bbn.hp.com) wrote:
: Jan@Bytesmiths.com (Jan Steinman) writes:

: > This has been discussed to death, but the bottom line is that if you need
: > arbitrary precision, you cannot use Float or Double, rather used Fraction
: > or Fixed. If you don't need arbitrary precision, but you'd like more than
: > what you're getting, use Double instead of Float. And never, ever use
: > Float in a financial application, unless you're a millionaire who doesn't
: > care about the value of a single dollar!
: > 

: Right ! For such things you should use BCD-coded Fixed's. 

Wrong! (sorry for that, I won't do it anymore :-)
There is a common misconception that for representing financial values
you need to have BCD-coded numbers.

As long as you're dealing with integers, the number system used is
completely irrelevant. You could use base-2, base-10, base-16 or even
base-13, with identical results (one exception: the representable
range of numbers with a given number of bits is highest when you
use 2 as the base, and gets lower with base-13 or base-10).

Fixeds are a special case of fractions, which can be represented
with integers alone. Decimal fixeds are simply fractions whose
denominator is a power of 10. Whether you represent numerator and
denominator in BCD or binary or base-13 is completely irrelevant.

BCD coded numbers had their place when they would be mostly input/output
as decimal numbers (can you say Mainframe, Punched Cards, COBOL?)
and when the CPUs had special hardware to do BCD arithmetic.
Nowadays it's silly to do fixeds or integers in BCD.

BCD floats might be a different story, but basically they (like all floats)
are nothing more than fractions where the denominator is expressed as
a power of the base instead of as an integer. Using the base 10 here
has the advantage that written decimal numbers can be represented
exactly (within the limits of mantissa length).

--
+--- Hans-Martin Mosner -------- Senior Smalltalk Guru ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+--- <hmm@heeg.de> ------ URL:http://www.heeg.de/~hmm/ ---+
