The FPU can be accurate to 19 significant digits. Today, I was working on a short algo with large integers not exceeding 10^18 using the the FPU. Somehow, the results seemed incorrect.
After spending a good part of the day with my good friend Ollydbg and the Windows calculator, I finally realized that I had forgotten to use finit at the start of the app. as I normally do whenever I use the FPU.
Windows provides a program with a clean FPU on startup but with the Precision Control bits set for double precision, i.e. all computations are rounded to only 16 significant digits. In such condition, if a 17th or 18th digit of an integer is important (as for my algo), it got lost and resulted in erroneous results. :boohoo:
I hope that reporting this silly mistake will help others avoid getting more gray hair (or less hair). :lol ::)
Raymond
In the help file fphelp.hlp it says
Initializes the coprocessor and resets all the registers and flags to their default values.
On the 80387/486, the condition codes of the status word are cleared.
So what are the defaults ?
When you use finit, the precision control bits are set for extended double precision (full 80 bits) as default. However, when your program starts under Windows, the FPU is clear but the precision bits are set for double precision only. :(
Raymond
Hi Raymond,
i've just had a similar problem, i guess i did spend about 5-6 hours to figure out what the problem was..
I am trying to code a control (first attempt), and need to store the handle of the control in a variable to access it from a ThreadProc. Nothing easier to do... i thought and typed the following:
CustomControlProc Proc hCtrl:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
MOV EAX,uMsg
.IF EAX==WM_CREATE
mov edx,hCtrl
mov hCLPG,eax
As i am not familiar with threads (also my first try) i just wondered why my user-message using PostMessage within the ThreadProc never arrived. I did read all books i have, googled around the web in anything i could find related to Threads, Messages a.s.o., but could not get this thing working... it became suspicious to me that something was wrong with my handle but it seemed to be valid. I was just one step before posting it and ask for help...
However, i have learned a lot aboud threads and messages.. and it is good to know that there are more people with similar formative experiences :thumbu
Regards, Phoenix