Search code examples
installationnsis

Using NSIS Math Library: How to perform 'Power to'


I am attempting to use the NSIS Math Library to perform a Power calculation. I'm having alot of difficulty working out the Math library syntax.

How can I perform this calculation in NSIS: h ^= g;

Var h # example variables
Var g
Var a

# I am attempting to perform the following calculations in NSIS.
# I'm not sure how exactly to do it using the math library syntax?
# Do I need to include the Math.nsh library to use it?
# h ^= g;

# My attempt:
Math::Script "a = $h; b = $g; c = ?? a = Power(a,b,c); R0 = a"

Solution

  • It's quite similar to C/C++, to define a function that calculates XOR and returns the result, try;

    Math::Script 'myxor(h,g) (h^g);'
    

    After that myxor(3,2) will give you 3 XOR 2 = 1.