[DGD]Casting to int

Kris Van Hees aedil at alchar.org
Fri Jun 30 18:16:17 CEST 2000


On Fri, Jun 30, 2000 at 06:05:13PM +0200, Felix A. Croes wrote:
> Why does C truncate floats when casting them to integers?  Because the
> matching PDP-11 machine instruction works that way.  I do not consider
> this to be a good reason for languages other than C.  I would like LPC
> to evolve away from its C roots.  LPC did not have floats originally,
> and when I added them I did so in the way I thought best.

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.

Anyway, this is not an argument to have it changed.  I just wanted  to  know
what your choice was based on (regardless of whether I agree or not -  which
is highly irrelevant anyhow).

	Kris

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



More information about the DGD mailing list