News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MasmLib FloatToStr does not work for me

Started by jj2007, August 18, 2008, 09:24:46 AM

Previous topic - Next topic

jj2007

Quote from: raymond on August 20, 2008, 11:47:04 PM
You are provided with a clean FPU at the beginning of your program. However, the precision control is only set for 64-bit double-precision floats by Windows. If you need extended double-precision (full 80 bits precision), either you modify the Control Word accordingly or use finit.

I tested the state of the FPU at program start. To my surprise, I found this (using OllyDbg 2.0):

EDIT: I found the answer:
53 means the precision that can be applied to a Real8, 64 bits (this is what Windows gives you)
64 means the precision that can be applied to a Real10, 80 bits (this is what finit gives you)
So there is no "full 80 bits precision"
  :wink

- at ModuleEntryPoint : FCW 027F, NEAR, 53
- after performing finit : FCW 037F, NEAR, 64

5432109876543210
0000001001111111 027F
0000001101111111 037F

This is Windows XP SP2...
Any idea why this differs from your para, and/or where the exact behaviour is documented?
Thanks, JJ

include \masm32\include\masm32rt.inc
.code
start:
int 3 ; set a breakpoint in OllyDbg
finit
exit
end start

raymond

80-bit floats is the maximum precision you can get with the current FPU architecture. It consists of:
- 64 bits for the mantissa
- 15 bits for the biased exponent
- 1 bit for the sign.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com