Divide operator only accepts integer divisor?

Hi,

I am trying to use a Ramp to effect a fade out on the Audio File Player and wanted to use an exponential decay rather than linear.

Therefore I was calculating the new volume like this:
Exp = timeX / 1000
newVol = LaneVol * Power(0.75, Exp)

however the Exp only changes every second because the result is an integer.

I tried to change it as follows:
var
newVol : double
Exp: double
Sec: double

Sec = 1000.0
Exp = timeX / Sec
newVol = LaneVol * Power(0.75, Exp)

However this causes a compilation error on the line calculating the exponent:
Semantic error: Line 102, Col 15: Semantic error: Line 102, Col 15: Types are not compatible

It seems that you cannot divide a double by another double and therefore only integer division is possible?

Could you perhaps post the full script describing this issue ?

Without a complete script, it’s hard to know to what line 102 refers.

Also, “Exp” is the name of a function - you cannot declare it as a variable and you certainly can’t assign something to it

Thanks @dhj and @David-san, there were two problems - as you say one was that Exp is a function and the other was that I was trying to divide an integer by a double.

I was trying to divide timeX from the On TimePassing callback which is an integer by a double.
If I assign TimeX to a double first and use that in the expression it works fine.

So Integer divided by integer is OK and will return an integer and double divided by double is OK and will return a double but you can’t mix them.

Thanks for the help!

But you can turn an integer into a double (for purposes of evaluating an expression) by multiplying it by 1.0

In other words

var 
   i : integer
i / 3.2  

will not work but

(1.0 * i) / 3.2

will work just fine. In other words, it is the type of the first operand that drives the type of the expression in this example

That’s good to know, thanks!