"PercyP" <(E-Mail Removed)> wrote in message

news:cl3gkg$310$(E-Mail Removed)...

> Firstly sorry I posted to the wrong place, will put any further
beginner

> questions there.

>

> I thought it was something to do with the language rather than my
program.

> I've done the program in Pascal before with practically the same
algorithm

> and it worked perfect, as Pascal works with significant figures
rather than

> floating point. I'm happy now I know the answer! )

>

> Thanks!

>

> Percy

>
If it makes you feel any better (or worse?) this issue has been a

topic of conversation since at least the early days of Fortran.

Actually there are two safe ways to deal with money, one is to use

integers, the other is to use BCD arithmetic. The choice depends on

what you want to do. BCD arithmetic will allow fractional values to

be dealt with correctly (in general) so you can do things like

interest-rate calculations and get the expected result. But floating

point should never be used from money. There are some possibly

apocryphal stories of people in the early days of computing carrying

out computer fraud by calculating monetary amounts in floating point

and diverting the odd fractions to their own accounts.

--arne