0.25b0 vs 2.5b-1



On 10/9/05, Richard Fateman  wrote:

> 0.25b0-2.5b-1;
> if fpprec:18,  turns out not to be zero.
>
> It seems to me it is a bug... why would it be
> OK to convert something inaccurately to binary?

agreed -- looks like a bug to me too.

i am inclined to suppose that equivalent decimal representations
should become equivalent binary representations (whether the
conversion is exact or not). that might mean canonicalizing
the decimal representation before conversion. i haven't looked
at the code; maybe it is already trying to do that.

a few more data --

in both maxima / gcl and maxima / clisp,
  0.25b0 - 2.5b-1 => 0.0b0 when fpprec = 16 or 20,
  0.25b0 - 2.5b-1 => - 5.42101086242752217B-20 when fpprec = 18
   0.3b0 - 3b-1 => 0.0b0 when fpprec = 16, 18, or 20

in maxima / clisp,
  0.25e0 - 2.5e-1 => 0.0,
  0.3e0 - 3e-1 => 0.0

in maxima / gcl,
  0.25e0 - 2.5e-1 => 0.0
  0.3e0 - 3e-1 => - 5.5511151231257827E-17
  (gcl alone: (- 0.3e0 3e-1) => -5.5511151231257827E-17)

robert