1. Floating Point Numbers

It is a simple, if sad, truth that floating point numbers are unreliable.

If you want accurate representation of decimal and fractional numbers you must
use a
specialist library. These specialist libraries internally use integers. Only
integers are accurate
in computing. The IEEE has long recognized that floating point numbers are
in-accurate.
Their standard takes this into account.

There is no point considering the source code for euphoria. It is a compiled
language and the
order of operations is set by the compiler. There is in fact no guarantee in
order of operations
in C. This is often stated by C gurus when some one questions the results of
floating point
operations.

The only solution is to use integers only. For an assignment we had to take an
order an
calculate the cost. The floating point calculations were wrong. The costs were
in dollars and
cents. As it is a fixed position decimal I represented the prices in cents. When
I dealt with it, I
dealt with it in cents. I out-putted it as dollars and cents. This meant it was
accurate and the
user was not confused by incorrect results or prices in cents.
-------------------------
Sincerely,
Mathew Hounsell

mat.hounsell at excite.com

new topic     » topic index » view message » categorize

2. Re: Floating Point Numbers

Mathew Hounsell wrote:

>It is a simple, if sad, truth that floating point numbers are unreliable.

The floating point implementations are flawed. Floating point itself is
no more unreliable than it's limitations in significance...which are the
reason for it's existence in the first place. Because binary floating point
does not map one to one with decimal numbers does not make it
inherently inaccurate. It will many times make conversions between the
two difficult, but can be no less accurate than decimal numbers if used
exclusively.

The problem here is that we the programmers have no control over the
use of floating point or any other internal representation. Floating point
has it uses. Few if any other languages use floating point without
warning. For things like fixed length decimal calculations of money,
floating point actually slows things down. From what the manual says,
floating point is invoked the instant a decimal point is used. This is many
times inefficient and a source of error as you point out below.

>If you want accurate representation of decimal and fractional numbers you must
>use a
>specialist library. These specialist libraries internally use integers. Only
>integers are accurate
>in computing. The IEEE has long recognized that floating point numbers are
>in-accurate.
>Their standard takes this into account.

Decimal math libraries are not specialist libraries. For most of business use
and most ordinary mathematics, floating point is the specialist system. The
fact that tech-heads have created an upside down world in which the only
optimized math hardware that we have is floating point is just that, upside-
down.

>There is no point considering the source code for euphoria. It is a compiled
>language and the
>order of operations is set by the compiler. There is in fact no guarantee in
>order of operations
>in C. This is often stated by C gurus when some one questions the results of
>floating point
>operations.

See above. C lets the programmer determine when floating point is to be
used.

>The only solution is to use integers only. For an assignment we had to take an
>order an
>calculate the cost. The floating point calculations were wrong. The costs were
>in dollars and
>cents. As it is a fixed position decimal I represented the prices in cents.
>When I dealt with it, I
>dealt with it in cents. I out-putted it as dollars and cents. This meant it was
>accurate and the
>user was not confused by incorrect results or prices in cents.
>-------------------------
Most decimal fractional calculations can be and are handled in your
suggested manner. The problem there is in the understanding of significant
digits. Because of the normal dichotomy between "integer" and "floating
point" math, most people act as if something magic happens at the
decimal point. Especially in the finite integer world of the computer,
significant digits are significant regardless of which side of the point they
are found on.

A binary library for handling of decimal integer calculations would certainly
improve the accuracy of any business math in Euphoria. Of course, that
would require some agreement on representation of fractional numbers as
something other than floats.

Everett L.(Rett) Williams
rett at gvtc.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: Floating Point Numbers

----- Original Message -----
From: "Everett Williams" <rett at GVTC.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Tuesday, March 21, 2000 9:11 AM
Subject: Re: Floating Point Numbers

> Decimal math libraries are not specialist libraries. For most of business
use
> and most ordinary mathematics, floating point is the specialist system.
The
> fact that tech-heads have created an upside down world in which the only
> optimized math hardware that we have is floating point is just that,
upside-
> down.

Hey hey hey,, the 74181 and 10581 don't even know what a floating point is,
and they predate the 8087! The 10287 has no relation to the 80287, and i am
fairly sure it predates the 8087 too. All those are faster than the 8087
ever was, the 74181 coming in "F" and "S" versions, and the 10581 and 10287
being ECL. The hardware existed/exists , it's just that we don't use it.
Last time i researched math hardware addons for the intel x86 motherbds,
there was a dedicated math card that was software configureable on-the-fly
to some extent,, but that was 5yrs ago, and the card was more expensive than
the rest of the puter. The problem with hardware acceptance is that it takes
software to interface it to humans, and the humans haveto want it before it
becomes commercially viable.

> >The only solution is to use integers only. For an assignment we had to
take an order an
> >calculate the cost. The floating point calculations were wrong. The costs
were in dollars and
> >cents. As it is a fixed position decimal I represented the prices in
cents. When I dealt with it, I
> >dealt with it in cents. I out-putted it as dollars and cents. This meant
it was accurate and the
> >user was not confused by incorrect results or prices in cents.
> >-------------------------
>
> A binary library for handling of decimal integer calculations would
certainly
> improve the accuracy of any business math in Euphoria. Of course, that
> would require some agreement on representation of fractional numbers as
> something other than floats.

Well, if you are doing business math, shouldn't we recognize that not
everyone uses dollars and cents?

Kat

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu