Admin Password
decimal_to_fraction()

//argument0 = the number without decimal
//argument1 = the decimal
//argument2 = reduced or not reduced (true or false)

//E.g : decimal_to_fraction(11,12) -> 11,12

//it will return a fraction like this : 11/5

var xx yy decimal number sur fraction;

decimal = string(argument1);
number = string_length(decimal);
fraction = power(10,number);
sur = argument1+(argument0*fraction);
xx = sur;
yy = fraction;

if argument2 = true
{
while (xx mod 2)=0 && (yy mod 2)=0
{
xx = xx/2;
yy = yy/2;
}
while (xx mod 3)=0 && (yy mod 3)=0
{
xx = xx/3;
yy = yy/3;
}
while (xx mod 4)=0 && (yy mod 4)=0
{
xx = xx/4;
yy = yy/4;
}
while (xx mod 5)=0 && (yy mod 5)=0
{
xx = xx/5;
yy = yy/5;
}
while (xx mod 6)=0 && (yy mod 6)=0
{
xx = xx/6;
yy = yy/6;
}
while (xx mod 7)=0 && (yy mod 7)=0
{
xx = xx/7;
yy = yy/7;
}
while (xx mod 8)=0 && (yy mod 8)=0
{
xx = xx/8;
yy = yy/8;
}
while (xx mod 9)=0 && (yy mod 9)=0
{
xx = xx/9;
yy = yy/9;
}
}
return string(xx)+"/"+string(yy)
This page has been viewed 60 times
Free Text Host is brought to you by Dagon Design
This site contains no adware, spyware, or popups
Questions? Comments?