 # don't understand float

I was varying a float variable called "lfoAmmount", and this line worked fine:

``````pitch=(pitch+(getLfoValue(lfoType)/lfoMaxValue)*lfoAmmount);
``````

pitch is also float and contained decimals.

I read that floats are a little heavy for proccesing, so I want now to convert "lfoAmmount" to integer, but when I run this line:

``````pitch=(pitch+(getLfoValue(lfoType)/lfoMaxValue)*float(lfoAmmount/10)));
``````

Now pitch doesn't have any decimals.

Also I tryed doing this and it does the same:

``````pitch=(pitch+(getLfoValue(lfoType)/lfoMaxValue)*float(lfoAmmount/10)));
``````

What's the problem?

a little clarification, when I said

"convert lfoAmmount" to integer

I meant defining it as integer.

Now I tryed defining it float again and when running this:

``````pitch=(pitch+(getLfoValue(lfoType)/lfoMaxValue)*lfoAmmount/10));
``````

it's working fine. So... it needs to be float??

Pancra85: a little clarification, when I said

"convert lfoAmmount" to integer

I meant defining it as integer.

Now I tryed defining it float again and when running this:

``````pitch=(pitch+(getLfoValue(lfoType)/lfoMaxValue)*lfoAmmount/10));
``````

it's working fine. So... it needs to be float??

Not sure I understand your problem, but suspect that you are forcing a conversion to integer by using that /10 value in your expression. Try using 10.0

pitch=(pitch+(getLfoValue(lfoType)/lfoMaxValue)float(lfoAmmount/10.0*)));

I think the title should have been "don't understand int". Ints don't have decimals! Also, you can't divide properly using ints. Consider that 1 divided by 2 equals zero using integer math.

Also, you can't divide properly using ints.

You most certainly can. The results will be exactly what you'd expect, if you expected the result to have been performed using integer math.

Ints don't have decimals!

They most certainly do, all of them to the left of the decimal point.

AWOL: all of them to the left of the decimal point.

Although you can move some of them to the right by using fixed-point numbering.

I read that floats are a little heavy for proccesing, so I want now to convert “lfoAmmount” to integer, but when I run this

What are your performance requirements? Are the operations occurring too slow for your needs?

Relative to integer operations, floating point operations are pretty slow. Relative to human perception, they are still extremely fast.

Also, converting a single datum from float to int, then performing floating point operations on that datum is going to do nothing to improve performance. In fact, it’s going to hurt it, since that datum now has to be converted to float before it can perform the float operation on it.