The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: georgek01 on September 07, 2006, 03:17:13 PM

Title: Help with StrToFloat
Post by: georgek01 on September 07, 2006, 03:17:13 PM
Hello!

I need to convert two strings to floating point numbers, then compare them to get the lowest. The follwoing code doesn't work however...



szNum1 db '0.1457',0
szNum2 db '0.1568',0

...

fpNum1 QWORD ?
fpNum2 QWORD ?

...

invoke StrToFloat, addr szNum1, addr fpNum1
invoke StrToFloat, addr szNum2, addr fpNum2

.if fpNum1 > fpNum2 ; compiler doesn't like this

.else

.endif

...


You assistance will be greatly appreciated!!
Title: Re: Help with StrToFloat
Post by: mnemonic on September 07, 2006, 04:06:44 PM
Hi georgek01,

the comparison will not work that way.

You have to do that manually yourself via the FPU or you can use the FpuComp Function which comes in a library with the MASM32 package.
For details regarding FpuComp I suggest you have a look into \masm32\help\fpulib.hlp.

Regards
Title: Re: Help with StrToFloat
Post by: georgek01 on September 07, 2006, 04:17:40 PM
Thanks mnemonic for the response.  :U

I'll have a look there.