Re: understanding floats

From: David Steuber (david_at_david-steuber.com)
Date: 09/28/04


Date: 28 Sep 2004 12:39:29 -0400

Ron Garret <rNOSPAMon@flownet.com> writes:

> The basic problem is easy to understand: 0.1 (a.k.a. 1/10) is a
> repeating decimal when represented in base 2.
>
> It is possible (and actually makes an educational and very doable
> exercise) to write floating point math routines that represent numbers
> in base 10 which do not suffer from this problem. (Of course, there is
> an analogous problem for a base 10 representation when dealing with
> fractions that are infinitely repeating decimals in base 10, like 1/3,
> 1/7, etc.)

I seem to recall that the 80387 math coprocessor had BCD instructions
and represented BCD numbers in 80 bits. I also seem to recall the
Borland C++ 2.0 compiler supporting BCD arithmetic although I don't
recall the declerations you needed to use to make BCD numbers.

Babbage's difference machine used decimal numbers, IIRC.

Would we count in octal if we had no pinkies?

-- 
An ideal world is left as an excercise to the reader.
   --- Paul Graham, On Lisp 8.1


Relevant Pages

  • Re: understanding floats
    ... >> exercise) to write floating point math routines that represent numbers ... > I seem to recall that the 80387 math coprocessor had BCD instructions ... > and represented BCD numbers in 80 bits. ... I also seem to recall the ...
    (comp.lang.lisp)
  • Re: In what language do you think?
    ... In fact, photons are as real as molecules, and a distinction between ... representation; hence I doubt whether our sensual organs are involved ... recall some picture, music or odor, I neither see nor hear or smell. ...
    (sci.lang)
  • Machine code for farmers who want their heads to spin.
    ... As I recall sometimes ... > if I wanted to be sure of the representation. ... completely unfit for any form of commercial programming. ... machine code. ...
    (uk.business.agriculture)
  • Re: in which form real and integer values are saved in memory
    ... >> twos complement, BCD or others. ... BP> I don't think that BCD is a valid representation for C integer ... essentially the entire program state at every point). ...
    (comp.lang.c)
  • Re: What about big integers in Ada 2005?
    ... > BCD was originally a six bit representation. ... > the advent of the byte on the IBM System 360, BCD became Extended Binary ... The 6-bit character code was BCDIC -- Binary Coded Decimal Interchange ... > in the picture and a nibble for the sign. ...
    (comp.lang.ada)