Re: Little Endian -> Big Endian (Ada95 / GNAT), Whats with floating point types?

From: Hyman Rosen (hyrosen_at_mail.com)
Date: 03/04/04


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/>.



Relevant Pages

  • Re: n-ary representation and divisibility
    ... >Recently I have an observation about algorithms on divisibility of ... >But we perform all these algorithms mostly under decimal representation ... What about for different n-ary representation? ... The reason why a number in decimal form is divisible by 3 iff the sum ...
    (sci.math)
  • Re: hi everyone, i had s.ome questions about holographic information
    ... post-offset need to be stored for each base representation, ... i've not come across any algorithms like it, but as i can just see it ... To have a stream type compression with advanced algorithms (even ... since in this analogy the data set size is only limited by the memory ...
    (comp.compression)
  • Re: n-ary representation and divisibility
    ... > times the leftmost group and add on the second leftmost group, ... > But we perform all these algorithms mostly under decimal representation ... What about for different n-ary representation? ... > for m-ary representation of a. ...
    (sci.math)
  • Representation of Triangle Meshes
    ... i'm currently searching for an adequate representation of triangle ... I know that the choice of representation heavily depends on the ... * meshes as indexed face lists stores pointers ... A lot of algorithms I deal with require fast access for neighborhood ...
    (comp.graphics.algorithms)
  • Re: How do you keep track of what all the numbers mean?
    ... that if you develop a floating point representation of a system, ... but I would suspect that scaling constants is a main part of it. ... There will be an assumed scaling between the floating point ... will depend upon the input signal power. ...
    (comp.dsp)

Loading