News:

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

FloatToStr2 80 bit long

Started by s3rh47, April 02, 2010, 06:51:08 AM

Previous topic - Next topic

s3rh47

Hello  I have  a problem

How can a 80 bit long FloatToStr2

for example

.data

x1 dt ?  ; this is TBYTE

. code

ST= 1.8893108197026365050E+18

FSTP x1

invoke FloatToStr2, x1, addr buffer

As there is an error FloatToStr2 is long for 64 bit

I want to do later so a string =  (ASCII "1,88931081970264E18")

Thanks for help

MichaelW

For a REAL10 you can use Raymond's FPULIB. A version is included in the MASM32 package, and a newer one is available here:

http://www.masm32.com/board/index.php?topic=13074.0

This is a quick test using the value of pi, and including the results for two C compilers that support long doubles:

;=========================================================================
    include \masm32\include\masm32rt.inc
    include \masm32\fpulib\fpu.inc
    includelib \masm32\fpulib\fpu.lib
;=========================================================================
    .data
        r8     REAL8  ?
        r10    REAL10 ?
        buffer db     40 dup(0)
    .code
;=========================================================================
start:
;=========================================================================
    print " 3.141592653589793238462...",13,10

    fldpi
    fstp r8
    fldpi
    fstp r10

    invoke FloatToStr2, r8, ADDR buffer
    print " "
    print ADDR buffer,"       FloatToStr2, r8",13,10

    invoke crt_printf, cfm$(" %.15f        "), r8
    print "crt_printf %.15f r8",13,10

    invoke FpuFLtoA, ADDR r10, 15, ADDR buffer, SRC1_REAL or SRC2_DIMM
    print ADDR buffer,"        FpuFLtoA 15 decinal digits r10",13,10

    ;--------------------------------------------------
    ; This was done with an old DOS version of Turbo C
    ; that still supported long double (REAL10).
    ;---------------------------------------------------

    print " 3.1415926535897932400    Turbo C printf %.19Lf r10",13,10


    ;-----------------------------------------------------------------
    ; This was done with a Digital Mars C/C++ compiler from 2007, the
    ; runtime libary for which still supports long double (REAL10).
    ;-----------------------------------------------------------------

    print " 3.14159265358979323850   DM printf %.20Lf r10",13,10

    inkey "Press any key to exit..."
    exit

;=========================================================================
end start


3.141592653589793238462...
3.1415926535897932       FloatToStr2, r8
3.141592653589793        crt_printf %.15f r8
3.141592653589793        FpuFLtoA 15 decinal digits r10
3.1415926535897932400    Turbo C printf %.19Lf r10
3.14159265358979323850   DM printf %.20Lf r10

eschew obfuscation

s3rh47

Juppi thanx for your help  :U