Float Variables?
propwell
Posts: 87
Hi there,
i hope i'm not annoying you with such a stupid question, but i'm trying to solve it since several hours, ans still can't find any solution.
My Problem is:
if got a code like this:
so i want to print the percentage of how far my repeat-function has come.
But i can't find any solution on how to deal with this float-expression...
Can you please help me?
Thanks a lot!
i hope i'm not annoying you with such a stupid question, but i'm trying to solve it since several hours, ans still can't find any solution.
My Problem is:
if got a code like this:
repeat i from 0 to 50 { do somethin with i } stat := i/50*100 gr.textmode(3,3,6,5) gr.text(0, -50, num.ToStr( stat , Num#DEC ))
so i want to print the percentage of how far my repeat-function has come.
But i can't find any solution on how to deal with this float-expression...
Can you please help me?
Thanks a lot!
Comments
You can use scaled integers for your program.· For example, you could calculate "stat" in percent like this:
stat := (i *100) / 50
This gives you an integer from 0 to 100 for values of i from 0 to 50.· In this particular case, you could just use i * 2 for your percent.
·
If you were looping over 624 things, you would do this:
...and if you wanted 10ths of a percent, you'd do this:
...in which case your answer would range from 0 to 1000 instead of 0 to 100. This is called 'fixed point' math, since you're representing a decimal point by just maintaining your numbers with a constant scaling factor multiplied in.
Jason