[DGD]Casting to int

E. Harte harte at xs4all.nl
Fri Jun 30 18:29:39 CEST 2000


On Fri, 30 Jun 2000, Kris Van Hees wrote:

<...>
> 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.

To each their own.  If you want the C/Java-like behaviour, do this:

  (int)(float_value - 0.5)    if float_value >= 0
  (int)(float_value + 0.5)    if float_value <  0

Shouldn't be too hard to turn that into a nice #define or function.

> 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).

Indeed. :)

Erwin.
-- 
Erwin Harte  -  Forever September, 2495 and counting  -  harte at xs4all.nl
[ 4:20pm  up 13 days, 45 min,  5 users,  load average: 0.00, 0.03, 0.04 ]


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



More information about the DGD mailing list