01.06.2012, 10:29
the modulo operator returns the remainder of 2 integers. for floats, you simply need to reinvent the formula:
10.0 / 4.0 = 2.5
round_floor of 2.5 = 0.5
0.5 * 4.0 = 2.0
...looks similar to
10 % 4 = 2
another test: 100.0 % 3.0
100.0/3.0=33.333333
0.333333*3.0=1.000000
100%33=1![Smiley](images/smilies/smile.png)
oh, i forgot to mention
3600.0/1500.0=2.4
0.4*1500=600
3600.0%1500.0=600
oops i made a mistake there. the floor is NOT the method to round, it takes the main part instead of the small parts... moment. editing post (again) lol
here is the solution: the floatround_floor returns the big part %f.0, subtracted that from the whole number %f, will return the little %.f part:
3600.0 / 1500.0 = 2.4
floatround of 2.4 = 2.0 // i forgot this to create the small number...
2.4 - 2.0 = 0.4 //incl. this line..
0.4 * 1500.0 = 600.0
did i miss something again?
Код:
new Float:a=10.0; new Float:b=4.0; new result=floatround((a/b),floatround_floor)*b;
round_floor of 2.5 = 0.5
0.5 * 4.0 = 2.0
...looks similar to
10 % 4 = 2
another test: 100.0 % 3.0
100.0/3.0=33.333333
0.333333*3.0=1.000000
100%33=1
![Smiley](images/smilies/smile.png)
oh, i forgot to mention
3600.0/1500.0=2.4
0.4*1500=600
3600.0%1500.0=600
oops i made a mistake there. the floor is NOT the method to round, it takes the main part instead of the small parts... moment. editing post (again) lol
here is the solution: the floatround_floor returns the big part %f.0, subtracted that from the whole number %f, will return the little %.f part:
Код:
new result=((a/b)-floatround((a/b),floatround_floor))*b;
floatround of 2.4 = 2.0 // i forgot this to create the small number...
2.4 - 2.0 = 0.4 //incl. this line..
0.4 * 1500.0 = 600.0
did i miss something again?