why not consfold sin(const)
Zack Weinberg
zack@codesourcery.com
Sun Sep 19 20:56:00 GMT 2004
Luchezar Belev <l_belev@yahoo.com> writes:
>> Yes, but it does not stretch as far as giving complete junk results,
>> which is what would happen in some cases if you used host functions.
>
> I see. I'm surprised that in the compiler there is no sin/cos/log/etc. funcs
> already implemented for other reasons.
I'm not sure about exp/log, but trigonometric functions are
substantially harder to implement with accuracy over their entire
domain (i.e. the range of the floating-point type) - to do argument
reduction, glibc has a table giving 2/pi to 5628 hexadecimal digits!
This is the sort of thing where we'd probably take a patch if someone
wrote one, but we don't consider it very important, certainly not
compared to how hard it would be to code. And I think you are
seriously underestimating the difficulty.
> What are the requirements for possible implementation of such functions?
> - precision of somewhere about the long double (64-bit mantissa)
gcc uses an internal floating point representation with *at least* 160
bits of mantissa. You would need to be accurate to that many bits at
least for all values with exponent 0 (ignoring bias).
> - the speed doesn't matter too much
Yeah.
zw
More information about the Gcc
mailing list