Number Conversions

"It's still web development, it's just way easier!"

Numbers

Decimal, Fraction, Percent

Default: Automatically converts to the value given.

Also, Fraction can have a custom denominator appended (1.666 or 1.7(Decimal,Fraction3) will yeild the closest fraction in 3rds, 1 2/3). Fractions only are broken down against prime numbers up to 997.

The inline function, ordinal, is also available for converting positive integers into ordinal suffixes (1 to 1st, 2 to 2nd, etc).

Is Type Convert To Test Value Test Result
Decimal Fraction3 <#Test = -1.5> <#Test(Decimal,Fraction3)> -1 2/3
Decimal Fraction16 <#Test = -0.2525> <#Test(Decimal,Fraction16)> -1/4
Fraction Fraction4 <#Test = -13/16> <#Test(Fraction,Fraction4)> -3/4
Fraction Fraction <#Test = 1 10/12> <#Test(Fraction,Fraction)> 1 5/6
Decimal Fraction <#Test = -64.001> <#Test(Decimal,Fraction)> -64 1/1000
Decimal Percent <#Test = -0.975> <#Test(Decimal,Percent)> -97.5%
Fraction Decimal <#Test = -3 1/8> <#Test(Fraction,Decimal)> -3.125
Fraction Fraction <#Test = -3 16/24> <#Test(Fraction,Fraction)> -3 2/3
Fraction Percent <#Test = -90/100> <#Test(Fraction,Percent)> -90%
Percent Decimal <#Test = -145.5%> <#Test(Percent,Decimal)> -1.455
Percent Fraction <#Test = -175%> <#Test(Percent,Fraction)> -1 3/4
Percent Fraction4 <#Test = 30%> <#Test(Percent,Fraction4)> 1/4

Automatic type detection using a variable:

Decimal Fraction <#Test = -5.25> <#Test(Fraction)> -5 1/4
Decimal Percent <#Test = -0.25> <#Test(Percent)> -25%
Fraction Decimal <#Test = 1 1/4> <#Test(Decimal)> 1.25
Fraction Percent <#Test = 1/4> <#Test(Percent)> 25%
Percent Decimal <#Test = 25%> <#Test(Decimal)> 0.25
Percent Fraction <#Test = 25%> <#Test(Fraction)> 1/4

Automatic type detection using a value directly:

Decimal Fraction 3.25 <#3.25(Fraction)> 3 1/4
Decimal Percent 0.25 <#0.25(Percent)> 25%
Fraction Decimal 3 1/4 <#3 1/4(Decimal)> 3.25
Fraction Percent 1/4 <#1/4(Percent)> 25%
Percent Decimal 25% <#25%(Decimal)> 0.25
Percent Fraction 25% <#25%(Fraction)> 1/4