106
Modification Help / Re: "String always evaluates to 0" and finding a ratio
« on: July 07, 2011, 10:03:14 PM »
Oh I already solved this, yet the function I made checks every denominator and sees if it gets a fraction 0.000001 from the number you enter.
Code: [Select]
function getratio(%ratio,%i)
{
if(%i $="")
{
%i=1;
}
else if(%i<99999)
{
%raat = %ratio*%i;
%rate = mCeil(%raat - 0.5);
%diff = %raat - %rate;
if(%diff <= 0.000001 && %diff >= -0.000001)
{
%raat = mCeil(%raat - 0.5);
echo(%raat@":"@%i);
return %raat@":"@%i;
}
else
{
getratio(%ratio,%i++);
}
}
else
{
echo("Denominator is greater than 100000");
echo(%ratio@":1");
return %ratio@":1";
}
}

