27.03.2013, 13:41
I am not sure whether you will understand me, but I'll try to explain what I want.
I need a function, which gets one float value, then finds the most closest value to the first one, which can be divided by a spefic value without modulo. It sounds like a real mess, right? So I will try to explain in examples:
I hope you understood what thia function must do. WHo has any solution of this?
I need a function, which gets one float value, then finds the most closest value to the first one, which can be divided by a spefic value without modulo. It sounds like a real mess, right? So I will try to explain in examples:
pawn Код:
//let's call our function FindClosestVal
stock FindClosestVal(Float:inputval,Float:divisor);//where inputval is a float value we input, and divisor is a value by which the final value can be divided
//Let's look at this example script:
new Float:a;
a=FindClosestVal(10.0, 3.0);
//If the function is right, we will get a=9, as 9 is the most closest value to 10, which can be divided by 3
new Float:b;
b=FindClosestVal(4.45, 1.5)
//in result we will get b=3, because 3 is the closest to 4.45 value which can be divided by 1.5