Tim Roberts wrote:
> Bin Xin <spamtrap@[EMAIL PROTECTED]
> wrote:
>> printf("%.3f\n", my_pow(2.0, 35.3));
>> <<<
>> outputs:
>>
>> 42301799935.756
>> 2.000
>>
>> In other words, the first invocation get the right results, but not
>> the second one. My intuition is that both log and pow are pure
[snip]
>
> I admit that I lost track part way through, but it looks to me like you
> aren't cleaning up the floating point stack when you are done. If you
> leave stuff on the stack, sooner or later the stack will overflow (there
> are only 8 entries, after all), which triggers floating point
exceptions.
Tim is almost certainly right!
The easy way to check this is to call your my_pow() function in a loop,
preferably while inside the debugger, and watch the x87 stack contents.
Anyway, if you're going to get rid of pow/log, do you still need full
double precision results?
You can do lots of fun stuff with polynomial approximations. :-)
For a sw DX9/DX10 implementation I came up with ways to do this with
sufficient precision that were one or two orders of magnitude faster
than the x87 hw stuff.
Terje
--
- <Terje.Mathisen@[EMAIL PROTECTED]
>
"almost all programming can be viewed as an exercise in caching"


|