- Joined
- Aug 3, 2008
- Messages
- 2,345
Ok, so i want a Fraction object, simply because I find it easier to work in fractions than decimals personally. I want a method to work out a fraction from a decimal. How would I do this? (I know it's possible because my calculator can do it)
JASS:
library Fraction
struct Fraction
integer num
integer den
real value
static method create takes integer num, integer den returns Fraction
local Fraction f = Fractionn.allocate()
set f.num = num
set f.den = den
set f.value = I2R(num)/I2R(den)
return f
endmethod
static method createFromReal takes real value returns Fraction
local Fraction f = Fraction.allocate()
set f.value = value
//what here???
return f
endmethod
endstruct
endlibrary