Liking cljdoc? Tell your friends :D

emmy.bigfraction

A CLJS bigfraction is a coprime pair of JavaScript BigInts, with the sign carried in the numerator.

A CLJS bigfraction is a coprime pair of JavaScript BigInts, with the
sign carried in the numerator.
raw docstring

->normal-formcljs

(->normal-form a b)

We assume we are given two BigInts, with b > 0. The GCD is divided out, and the sign is carried in the numerator.

We assume we are given two BigInts, with b > 0. The GCD is divided out, and the
sign is carried in the numerator.
sourceraw docstring

->realcljs

(->real q)

Coerce a fraction to real by performing the division in the floating point domain

Coerce a fraction to real by performing the division
in the floating point domain
sourceraw docstring

abscljs

(abs x)

Absolute value of the fraction x.

Absolute value of the fraction `x`.
sourceraw docstring

addcljs

(add x y)

Returns the sum of x and y.

Returns the sum of `x` and `y`.
sourceraw docstring

bigint-gcdcljs

(bigint-gcd a b)

GCD assuming a and b are BigInts > 0

GCD assuming a and b are BigInts > 0
sourceraw docstring

ceilcljs

(ceil x)

Ceiling. Result is a BigInt.

Ceiling. Result is a BigInt.
sourceraw docstring

cmpcljs

(cmp x y)

Compares the fractions x and y, returning -1, 0, or 1.

Compares the fractions `x` and `y`, returning -1, 0, or 1.
sourceraw docstring

denominatorcljs

(denominator x)
source

divcljs

(div x y)

Returns the quotient of x and y.

Returns the quotient of `x` and `y`.
sourceraw docstring

division-by-zerocljs

(division-by-zero)

Throws JS exception used to signal an attempt to construct a fraction with zero denominator.

Throws JS exception used to signal an attempt to construct a fraction
with zero denominator.
sourceraw docstring

eqcljs

(eq x y)
source

floorcljs

(floor x)

Floor. Result is a BigInt.

Floor. Result is a BigInt.
sourceraw docstring

gcdcljs

(gcd x y)
source

integer->cljs

(integer-> n)

Create a fraction with unit denominator.

Create a fraction with unit denominator.
sourceraw docstring

integer-powercljs

(integer-power x n)

Raises the fraction x to the integer power n.

Raises the fraction `x` to the integer power `n`.
sourceraw docstring

invertcljs

(invert x)

Returns the reciprocal of x, but throws if $x=0$.

Returns the reciprocal of `x`, but throws if $x=0$.
sourceraw docstring

makecljs

(make a b)

Produces a fraction in canonical form. Note that the canonical form of an integer is an integer, so if (one? b) you just get a.

Produces a fraction in canonical form. Note that the canonical form of an integer is
an integer, so if `(one? b)` you just get a.
sourceraw docstring

mulcljs

(mul x y)

Returns the product of x and y.

Returns the product of `x` and `y`.
sourceraw docstring

negcljs

(neg x)

Negation of the fraction x.

Negation of the fraction `x`.
sourceraw docstring

neg?cljs

(neg? x)

True if $x<0$.

True if $x<0$.
sourceraw docstring

numeratorcljs

(numerator x)
source

one?cljs

(one? x)

Returns true iff x is a unit fraction.

Returns true iff `x` is a unit fraction.
sourceraw docstring

promotecljs

(promote x)

If the fraction has a unit denominator, return the numerator, else the fraction.

If the fraction has a unit denominator, return the numerator, else the fraction.
sourceraw docstring

quotientcljs

(quotient x y)

Fractions form a field, so somewhat dubiously the function returns the largest integer N for which $Ny\le x$.

Fractions form a field, so somewhat dubiously the function returns
the largest integer N for which $Ny\le x$.
sourceraw docstring

real->cljs

(real-> x)

Clojure converts the real to BigDecimal and rationalizes from that. The JVM documentation explains that the BigDecimal value will correspond to what would be printed for the double value. We attempt to do the same thing here by converting to a string and converting from there.

Clojure converts the real to BigDecimal and rationalizes from that.
The JVM documentation explains that the BigDecimal value will correspond
to what would be printed for the double value. We attempt to do the
same thing here by converting to a string and converting from there.
sourceraw docstring

remaindercljs

(remainder x y)

If $q$ is (quotient x y), returns $x-qy$.

If $q$ is `(quotient x y)`, returns $x-qy$.
sourceraw docstring

subcljs

(sub x y)

Returns the difference of x and y.

Returns the difference of `x` and `y`.
sourceraw docstring

zero?cljs

(zero? x)

Returns true iff x is a zero fraction.

Returns true iff `x` is a zero fraction.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close