From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Float & precision
Date: 1999/10/17
Date: 1999-10-17T00:00:00+00:00 [thread overview]
Message-ID: <7udvu1$th$1@ash.prod.itd.earthlink.net> (raw)
In-Reply-To: 380b47e6.444543814@news.dsuper.net
<fluffy_pop@dsuper.net> wrote in message
news:380b47e6.444543814@news.dsuper.net...
> On Sun, 17 Oct 1999 05:23:55 -0500, "David C. Hoos, Sr."
> <david.c.hoos.sr@ada95.com> wrote:
>
><snip>
> Of course this will not work as simply as that since my intermediate
> result could be of any order of magnitude with positive or negative
> exponent. So I may have to multiply it by 10^x or divide it by 10^x,
> and then I'd have to figure out what x should be based on the
> intermediate result, so as to bring the value within the interger or
> long integer's range.
>
> Will a typecast into a discrete (integer) value not eliminate those
> non significant digits, thus rounding to a specific position ?
>
No. Not unless your integer has more bits than the mantissa of the
floating point type, and then, only if a scale factor is chosen such
that there is no overflow.
By the way, "typecast" is not an Ada term. You probably mean
"type conversion" or "type convert."
> I'm just sort of playing, going beyond the scope of my school work,
> trying to think of a relatively simple way to do it. After all my
> pocket calculator does it without problems. It's an old cheap Casio
> model. I don't know if operates with 32 or 64 bits or maybe something
> else.
The reason your pocket calculator _appears_ to do it without problems,
is that it does the calculations internally with a couple more digits
than it displays.
You can get the same effect in Ada with the gnat compiler by doing
your computations in long_long_float, then converting to long_float
for display.
next prev parent reply other threads:[~1999-10-17 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3807ba57.277208181@news.dsuper.net>
[not found] ` <slrn80goik.62n.gisle@apal.ii.uib.no>
[not found] ` <38088ba5.330797551@news.dsuper.net>
[not found] ` <7uc86m$cob$1@holly.prod.itd.earthlink.net>
1999-10-17 0:00 ` Float & precision fluffy_pop
1999-10-17 0:00 ` David C. Hoos, Sr. [this message]
1999-10-19 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox