Class: Rational

Rational

new Rational(n, d, f)

Rational
Parameters:
Name Type Description
n Integer
d Integer
f boolean If f is true then skip cancel().
Source:
  • rational.js, line 39

Methods

<static> any(a, b) → {Rational}

Convert anything to Rational.
Parameters:
Name Type Description
a
b
Source:
  • rational.js, line 119
Throws:
ZeroDivisionError
Type
Error
Returns:
Type
Rational

<static> num(a, b, c) → {Rational}

Convert Number to Rational.
Parameters:
Name Type Description
a number Numerator
b number Denominator
c boolean
Source:
  • rational.js, line 89
Returns:
Type
Rational

<static> one() → {Rational}

1/1
Source:
  • rational.js, line 69
Returns:
1/1
Type
Rational

<static> str(a) → {Rational}

Convert String to Rational.
Parameters:
Name Type Description
a string ex.'-1/2'
Source:
  • rational.js, line 106
Returns:
Type
Rational

<static> zero() → {Rational}

0/1
Source:
  • rational.js, line 79
Returns:
0/1
Type
Rational

abs() → {Rational}

Source:
  • rational.js, line 196
Returns:
|this|
Type
Rational

add(b) → {Rational}

Parameters:
Name Type Description
b Rational
Source:
  • rational.js, line 267
Returns:
this + b
Type
Rational

clone() → {Rational}

Source:
  • rational.js, line 156
Returns:
Type
Rational

cmp(b) → {number}

Parameters:
Name Type Description
b Rational
Source:
  • rational.js, line 234
Returns:
1 (this > b) 0 (this = b) -1 (this < b)
Type
number

div(b) → {Rational}

Parameters:
Name Type Description
b Rational
Source:
  • rational.js, line 296
Returns:
this / b
Type
Rational

eq(b) → {boolean}

Parameters:
Name Type Description
b Rational
Source:
  • rational.js, line 212
Returns:
this == b
Type
boolean

equal(b) → {boolean}

Parameters:
Name Type Description
b Rational
Source:
  • rational.js, line 223
Returns:
this === b
Type
boolean

html() → {string}

Source:
  • rational.js, line 181
Returns:
Type
string

inv() → {Rational}

Multiplicative inverse (or reciprocal)
Source:
  • rational.js, line 246
Returns:
Type
Rational

mul(b) → {Rational}

Parameters:
Name Type Description
b Rational
Source:
  • rational.js, line 287
Returns:
this * b
Type
Rational

neg() → {Rational}

Source:
  • rational.js, line 204
Returns:
-this
Type
Rational

pow(b) → {Rational}

Parameters:
Name Type Description
b number
Source:
  • rational.js, line 305
Returns:
this^b
Type
Rational

sub(b) → {Rational}

Parameters:
Name Type Description
b Rational
Source:
  • rational.js, line 277
Returns:
this - b
Type
Rational

tex() → {string}

Source:
  • rational.js, line 187
Returns:
Type
string

toString() → {string}

Source:
  • rational.js, line 172
Returns:
Type
string

valueOf() → {number}

Source:
  • rational.js, line 164
Returns:
Type
number