Archive: Math operations with Float types


Math operations with Float types
Hi I have some problems with following code

Version is a floating point number which I reads from an .ini file as follows

ReadINIStr $Version $Path\SYS\myApp.ini Section1 Ver


and I do the follwing comparison

IntCmp $Version 1.4 is1.4 lessthan1.4 morethan1.4
is1.4:
Goto Label1
lessthan1.4:
;Show a message and quit
MessageBox MB_ICONINFORMATION|MB_OK "VERSION:
Quit
morethan1.4:
Goto Label2

But this never works if the version is Greater than or less than 1.4.

I tried with following too

${if} $Version < 1.4
This too doesnt work


Can any one tell me how to do this floating point operation with a sample code.I went through the math plugin .Its very difficult for a beginner to understand

Best regards

Joseph


Hi, you may want to have a look at the version manipulation functions.

KenA


Hi,

Version compare functions are useful.I dont want such lengthy functions.Only want to compare two floating point numbers

best regards

Joseph


You should use the functions from the Wiki. The math plug-in is an overkill for this. But if you really want...

Math::script "#[1.1 > 1.2, r0 = 1, r0 = 0]"
DetailPrint $0

Don't forget version strings don't necessarily work the same as floating point numbers. They sometimes have more than one decimal point as well. Using a version comparison function will future proof your installer.

-Stu


Hi all
thank you.This works

Math::script "#[f($AppVersion) < 1.4, R2 = 1, R2 = 0]"

Best regards

Joseph