How to display precision of a real number in console?

Started by etow, January 30, 2008, 12:27:14 PM

Previous topic - Next topic

etow

Hi

I need to know how to display a real number up to 5 digits to the right of decimal point.

Thanks

ToutEnMasm


etow


raymond

You could also use the FpuFLtoA function from the Fpu.lib (which comes with MASM32) to convert your real number to ASCII. If you do, PLEASE read the HELP file which comes with the library.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

ToutEnMasm

Quote
I downloaded strsafe.zip and strsafeinc.zip.

How do I use them in MASM?

Put the .inc in the \masm32\include directorie ,the lib in \masm32\lib as the others.
In your source:
Quote
include \masm32\include\strsafe.inc
includelib \masm32\lib\strsafe.lib

and then you can call the functions exactly as the sample show you.




etow

Hi ToutEnMasm,

Which functions do I call for displaying the real or floating point precision
by using the strsafe.inc and strsafe.lib?

Please reply soon

Thanks

GregL

etow,

You can not do it with only strsafe.inc and strsafe.lib, those functions only display strings. You need to use sprintf or FpuFLtoA to convert the floating-point variables to a string first. Another method is to use printf.


donkey

Quote from: etow on January 30, 2008, 12:27:14 PM
Hi

I need to know how to display a real number up to 5 digits to the right of decimal point.

Thanks

msvcrt.dll contains sprintf which can convert doubles to strings...

mov eax, offset double
invoke sprintf,offset buffer,"%#0.5f",[eax],[eax+4]
add esp,16

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable