Re: Different printed output with floating point numbers

From: Bob Carragher (
Date: Thu Mar 08 2001 - 07:28:06 GMT

My thanks to Dave Hayden for clarifying the issue about
which I was not clear:  my concern was not with the actual
binary representation of (decimal) numbers that cannot be
exactly represented, but with the fact that UPS would output
two different strings for the same (binary) value depending
upon how it is requested in the display area.  But Russ has
explained why that is the case:

> In fact, if you try the following program:
>    int main()
>    {
>        float foo = 1.3;
>        double food = foo;
>        return 0;
>    }
> Run under ups, stop on the return and display foo and food, you see 
>       main                                           bob.c:5
> 	       float <foo>                        1.3
> 	       double <food>                      1.29999995232
> The problem Bob reports arises in the C interpreter, where there is a
> conversion of intermediate float results to doubles.

That is "fine" with me.  I'm willing to deal with "problems"
such as these, that arise from internal representations and
differences in accuracy.  What bothered me was the fact that
UPS automatically converts all floating point numbers to
doubles to represent the result of expressions.  Would it be
hugely inconvenient for UPS to check on whether values in an
expression are just floats (or constants), and leave the
representation as a float?



This archive was generated by hypermail 2.1.4 : Wed Feb 13 2002 - 21:51:33 GMT