I have tried multiple times before to find a CRT where printf properly supported REAL10, that could be reasonably used from a Windows app coded in MASM. This time I tried the CRT from the lcc-win compiler system, that I got here:
http://www.cs.virginia.edu/~lcc-win32/ The good parts are that the CRT printf (and related) functions do support long double, and that the CRT appears to be, at least functionally, encapsulated in a DLL. The not so good part is that I don’t see a full 19 digits of precision.
;==============================================================================
; Build as a console app.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data
hMod dd 0
r8 REAL8 ?
r10 REAL10 ?
.code
;==============================================================================
start:
;==============================================================================
invoke LoadLibrary, chr$("C:\lcc\bin\lcclibc.dll")
mov hMod, eax
printf("%Xh\n",hMod)
invoke GetProcAddress, hMod, chr$("_printf")
mov ebx, eax
printf("%Xh\n\n",ebx)
printf("3.141592653589793238462...\n")
fldpi
fstp r10
fldpi
fstp r8
printf("%.20f\n",r8)
push DWORD PTR r10+8
push DWORD PTR r10+4
push DWORD PTR r10+0
push cfm$("%.20Lf\n\n")
call ebx
add esp, 16
inkey
exit
;==============================================================================
end start
10000000h
10008544h
3.141592653589793238462...
3.14159265358979310000
3.14159265358979324000
For reference, with an old DOS version of Turbo C I got:
3.14159265358979324000
And with a Digital Mars C/C++ compiler from 2007 (which used its own CRT instead of MSVCRT):
3.14159265358979323850
A few details that I noticed in doing this:
Long double is supported under Win64, but instead of the size being 12 bytes as it is for Win32 it had to be increased to 16 bytes.
Although not built in, there is support for a "qfloat" 352-bit floating-point type.