[DGD]Casting to int

Felix A. Croes felix at dworkin.nl
Fri Jun 30 18:37:24 CEST 2000


Kris Van Hees <aedil at alchar.org> wrote:

> I was not arguing the choice you made, other than that it suprised me.  I am
> not able to say whether C truncates because of the PDP-11 instruction set or
> not, because I do not have any reference at hand that describes the  reasons
> why the Bell Labs people made certain choices when designing C (and B didn't
> handle floats).  However, I consider it (personally) logical to truncate  on
> converting a floating point value to an integer because it does not  involve
> any explicit choice to be made on what rounding technique you use.  There is
> only one way to truncate a floating point value.

Truncating a float <is> a rounding technique.  It is called "rounding
towards zero."  The choice that you refer to, regarding the rounding
performed when a floating point value must be represented with fewer
bits, does not usually include rounding towards zero among its
alternatives, perhaps because it produces such inaccurate results.

In DGD, the rounding performed on a floating point value when cast to
an integer is consistent with the rounding performed on floating
point values in other cases.

Regards,
Dworkin

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list