Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?
From: Hyman Rosen (hyrosen_at_mail.com)
Date: 03/04/04
- Next message: Carroll-Tech: "Embedded tools"
- Previous message: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- In reply to: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- Next in thread: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- Reply: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 04 Mar 2004 13:34:41 -0500
Warren W. Gay VE3WWG wrote:
> you can still represent a machine dependant number with
> repeating decimal places
There are no such numbers (on any common hardware). Whether
it's IEEE, VAX, or any of a variety of other forms of hardware
floating point representation, all of them can be written
exactly as a finite length decimal number (not counting the
bit patterns which do not represent numbers, of course).
> 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 OP was converting out of and back into the same representation.
Given that, there are a pair of published algorithms which ensure
completely faithful translation. One algoritm takes a decimal
representation and converts it to the binary representation closest
in value (coin flip for ties) and the other finds a shortest decimal
representation for a binary number which will convert back exactly to
that binary.
The algorithms were both published in Proceedings of the ACM SIGPLAN
'90 Conference on Programming Language Design and Implementation.
G. L. Steele Jr. and J. L. White.
How to Print Floating Point Numbers Accurately.
W. D. Clinger
How to Read Floating Point Numbers Accurately
You can find free implementations of these algorithms in C at
<http://www.netlib.org/fp/>.
- Next message: Carroll-Tech: "Embedded tools"
- Previous message: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- In reply to: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- Next in thread: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- Reply: Warren W. Gay VE3WWG: "Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|