Skip to content
⌘ NSIS Forum Archive

Math operations with Float types

6 posts

josabraham#

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
josabraham#
Hi,

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

best regards

Joseph
kichik#
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
Afrow UK#
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
josabraham#
Hi all
thank you.This works

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

Best regards

Joseph