Returns a FoscFraction.
Fractions
| + | |
| - | |
| * | |
| / | |
| == | |
| === | |
| != | |
| < | |
| > | |
| <= | |
| >= | |
| abs | |
| asCompileString | |
| asFloat | |
| asInteger | |
| copy | |
| deepCopy | |
| div | |
| hash | |
| mod | |
| neg | |
| pow | |
| reciprocal | |
| sign | |
| storeArgs | |
| str |
| withDenominator |
Example
FoscFraction(3).cs;FoscFraction(3, 1)
FoscFraction(3.14159).cs;FoscFraction(355, 113)
FoscFraction(#[3,2]).cs;FoscFraction(3, 2)
FoscFraction(6,2).cs;FoscFraction(3, 1)
FoscNonreducedFraction(6,2).cs;FoscNonreducedFraction(6, 2)
FoscFraction().cs;FoscFraction(0, 1)Example
a = FoscFraction(3,2) + FoscFraction(1,2);
a.str;2/1Example
a = FoscFraction(3,2) + 0.5;
a.str;2/1Example
a = 1.5 + FoscFraction(1,2);
a.str;2/1Example
a = FoscFraction(3,2) - FoscFraction(1,2);
a.str;1/1Example
a = FoscFraction(3,2) - 0.5;
a.str;1/1Example
a = 1.5 - FoscFraction(1,2);
a.str;1/1Example
a = FoscFraction(3,2) * FoscFraction(1,2);
a.str;3/4Example
a = FoscFraction(3,2) * 0.5;
a.str;3/4Example
a = 0.5 * FoscFraction(3,2);
a.str;3/4Example
a = FoscFraction(3,2) / FoscFraction(1,2);
a.str;3/1Example
a = FoscFraction(3,2) / 0.5;
a.str;3/1Example
a = 1.5 / FoscFraction(1,2);
a.str;3/1Example
a = FoscFraction(3,2);
b = FoscFraction(6,4);
c = FoscFraction(2,1);
d = 2;
a == a; // truetrue
a == b; // truetrue
a == c; // falsefalse
c == d; // truetrue
d == c; // truetrueExample
a = FoscFraction(3,2);
b = FoscFraction(6,4);
c = FoscFraction(2,1);
d = 2;
a === a; // truetrue
a === b; // true !!!TODO: override for FoscNonreducedFractiontrue
a === c; // falsefalse
c === d; // truetrue
d === c; // truefalseExample
a = FoscFraction(3,2);
b = FoscFraction(6,4);
c = FoscFraction(2,1);
d = 2;
a != a; // falsefalse
a != b; // falsefalse
a != c; // truetrue
c != d; // falsefalse
d != c; // falsefalseExample
a = FoscFraction(3,2);
b = FoscFraction(6,4);
c = FoscFraction(2,1);
d = 2;
a < a; // falsefalse
a < b; // falsefalse
a < c; // truetrue
c < d; // falsefalse
d < c; // falsefalseExample
a = FoscFraction(3,2);
b = FoscFraction(6,4);
c = FoscFraction(2,1);
d = 2;
a > a; // falsefalse
a > b; // falsefalse
a > c; // truefalse
c > b; // truetrue
b > c; // falsefalseExample
a = FoscFraction(3,2);
b = FoscFraction(6,4);
c = FoscFraction(2,1);
d = 2;
a <= a; // truetrue
a <= b; // truetrue
a <= c; // truetrue
c <= d; // truetrue
d <= c; // truetrueExample
a = FoscFraction(3,2);
b = FoscFraction(6,4);
c = FoscFraction(2,1);
d = 2;
a >= a; // truetrue
a >= b; // truetrue
a >= c; // falsefalse
c >= d; // truetrue
d >= c; // truetrueExample
a = FoscFraction(-3,2).abs;
a.str;3/2Example
a = FoscFraction(1,4);
a.cs;FoscFraction(1, 4)Example
a = FoscFraction(3,2);
a.asFloat;1.5Example
a = FoscFraction(5,2);
a.asInteger;2Example
a = FoscFraction(3,2).div(FoscFraction(1,2));
a.str;3/1
a = FoscFraction(3,2).div(0.5);
a.str;3/1
a = 1.5.div(FoscFraction(1,2));
a.str;3/1Example
a = FoscFraction([1,4]);
b = FoscFraction([1,4]);
a.hash;-929596897
a.hash == b.hash;trueExample
a = FoscFraction(3,2) % FoscFraction(1,2);
a.str;0/1
a = FoscFraction(3,2) % 0.5;
a.str;0/1
a = 1.5 % FoscFraction(1,2);
a.str;0/1Example
a = FoscFraction(3,2).neg;
a.str;-3/2Example
a = FoscFraction(3,2) ** FoscFraction(2,1);
a.str;9/4
a = FoscFraction(3,2) ** 2;
a.str;9/4
a = 1.5 ** FoscFraction(2,1);
a.str;9/4Example
a = FoscFraction(3,2);
a.reciprocal.str;2/3Example
a = FoscFraction(3,4);
a.sign;1
a = FoscFraction(-3,4);
a.sign;-1Example
a = FoscFraction(3,2);
a.str;3/2Example
a = FoscNonreducedFraction(3,2);
a = a.withDenominator(4);
a.pair;[ 6, 4 ]