Re: [AD] div-by-zero... math3d.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Ben Davis wrote:
I honestly think the best solution would be to do the arithmetic using double-precision values. A float can go down to 1e-38 before it becomes subnormal (and slow) and starts losing precision. A double can go down to 1e-some_three_digit_number. So the smallest float, cast to double, and squared, would be will within the range of a double. As for efficiency, the FPU on an x86 processor probably does everything using 10-bit (the nonstandard 'long double') precision anyway, so we're not losing anything.

You are right, this is probably better. sqrt() takes and returns doubles anyway, so assuming sqrt is the bottleneck we hardly lose much speed with your approach.

Sven





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/