Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert number type in calculation equation
#1
Question 
Hi guys.
Is there a easy way to convert number type in calculation equation?

For example:
out 100*(1/2)
it return 0

But in real math calculation, it for sure will get a result of 50.
It is because (1/2) step gets a result of int 0 instead of 0.5 imo.

So I wonder what function I can add before (1/2) to make it get 0.5?
And make "out 100*(1/2)" return 50?

Thank u for the help in advance.
#2
Make some of the numbers double.

out 100*(1/2.0)
#3
Thank u, it works!
And then after I convert it to double, how I can convert it to int again?
#4
Macro Macro3246
Code:
int i1=100*(1/2.01)
out i1

int i2=Round(100*(1/2.01))
out i2
#5
Thank u.
I appreciate the help!


Forum Jump:


Users browsing this thread: 1 Guest(s)