From: "Warren W. Gay VE3WWG" <warren@ve3wwg.tk>
Subject: Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?
Date: Fri, 05 Mar 2004 12:34:30 -0500
Date: 2004-03-05T12:34:30-05:00 [thread overview]
Message-ID: <JR22c.15805$JZ6.481765@news20.bellglobal.com> (raw)
In-Reply-To: <40487ac1_1@127.0.0.1>
pburnand0-news@yahoo.com wrote:
> Warren W. Gay VE3WWG wrote:
>>Marius Amado Alves wrote:
>>>>... Also, there is a small performance penalty paid for
>>>>shuffling bits around to achieve platform independence.
>>>But surely less than converting to an ASCII image and back. (I suspect
>>>that, contrary to what has been indicated, the significant performance
>>>loss in the ASCII solution is of time, not space.)
>>>
>>>But the ASCII solution is a nice, safe one if you don't have the time or
>>>the will or the possibility to learn to use or just to use the
>>>compiler's. Remember Ada has the wonderful 'Image and 'Value attributes
>>>which take care of the conversion for you.
>>
>>I'm no floating point numeric expert, but by converting to
>>a standard, say IEEE floating point format, you can still
>>represent a machine dependant number with repeating decimal
>>places in a IEEE floating point format (I assume). Mind
>>you, this depends heavily upon the differences between the
>>two formats.
>
> Even if there is a standard format, using binary format, there is always the
> problem of the byteorder and such...
Of course, but that was not my point.
> Using ASCII is cool, because a number is always read from left to right...
> So you can write a floating point number in Ada on Linux and read it in a C
> program on Windows to store it in a double or a float. All combinations
> are possible...
ASCII is also more expensive in time and space. Not much
of a consequence when you transmitting a few numbers,
but is much different if you are transmitting millions
of them. It makes to plan for the worst case in some
of these situations.
>>By converting to ASCII, you lose that, unless you encode
>>the fact that the last digit repeats, in some way (like
>>the number "1.33333*", where * might represent "repeat").
>
> There are always losses.
Agreed.
> If you want to keep the number as exact as
> possible, you should use your Ada packages in a way to print the maximal
> number of decimals. You should always be able to control the format of the
> output.
>
> So there should be no numer so short as "1.33333", even with the lowest
> precision format...
I think you missed my point (repeating decimals).
>>If they don't do that, then the number has been rounded,
>>and thus does not quite represent the original value any
>>more ;-) (at a minimum, it is less faithful than it
>>could be).
>
> The floating point numbers are always rounded even in an FPU. No software,
> no hardware can handle an infinite number of digits...
Of course. But my point was that some hardware does keep
a bit (IIRC), that indicates that this is a repeating
digit (binary/decimal). The point of this is to reduce
error.
> Doing exactly the same calculation on different computer systems can even
> give largely different results.
No kidding.
--
Warren W. Gay VE3WWG
http://ve3wwg.tk
next prev parent reply other threads:[~2004-03-05 17:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-25 9:38 Little Endian -> Big Endian (Ada95 / GNAT) James Amor
2004-02-25 12:23 ` David C. Hoos
2004-02-26 15:43 ` James Amor
2004-02-26 5:59 ` Simon Wright
2004-02-27 20:38 ` Guillaume Foliard
2004-02-28 11:27 ` Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types? Joachim Schr�er
2004-02-29 16:32 ` Simon Wright
2004-03-04 5:32 ` pburnand0-news
2004-03-04 11:55 ` Little Endian -> Big Endian (Ada95 / GNAT),Whats " David C. Hoos
2004-03-04 13:12 ` Little Endian -> Big Endian (Ada95 / GNAT), Whats " Marius Amado Alves
2004-03-04 17:51 ` Warren W. Gay VE3WWG
2004-03-04 18:34 ` Hyman Rosen
2004-03-05 17:40 ` Warren W. Gay VE3WWG
2004-03-05 17:50 ` Warren W. Gay VE3WWG
2004-03-05 13:48 ` pburnand0-news
2004-03-05 17:34 ` Warren W. Gay VE3WWG [this message]
2004-03-05 17:53 ` Warren W. Gay VE3WWG
2004-03-05 13:29 ` pburnand0-news
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox