On Mon, Dec 05, 2005 at 01:21:53PM -0500, Joshua Boyd wrote:
> On Wed, Nov 30, 2005 at 06:50:31PM -0800, Stephen Williams wrote:
>
> > I think changing 10 to 10.0 in that case would do the trick. I was
> > going to say that everything is integer there, but when dealing with
> > pico-'s and femto-'s, the range may be such that you really do want
> > a real value instead of an integer, for its range.
>
> I didn't try going back and changing to a 10.0, however my thought about
> using 10.0 is that it might cause the compiler to choose the pow(float,
> int) function, which would reduce the precision over a double. Is float
> precision enough? If not, I think switching to a 10.0l would cause it
> to see the constant as a double, if I'm reading the C guide pulled up by
> Google correctly.
In C (and C++/objC, etc..), floating point constants are double by
default, to specify a single precision floating point constant
you have ta append an 'f' or 'F' suffix.
An 'L' suffix will force computations in "long double" mode, which
has at least 4 different implementations depending on architecture
and ABI, varying between "long double" being exactly the same as
"double" and 128 bit floating point with 113 bit mantissa.
It is basically impossible to rely on long double for anything
portable. It may also be implemented in software and be much
slower than anything sticking to double.
Regards,
Gabriel