@epicallan/money-ts
Version:
TypeScript library for type-safe and lossless encoding and manipulation of world currencies and precious metals
25 lines (24 loc) • 1.24 kB
TypeScript
import { Integer } from './Integer';
import { Natural } from './Natural';
import { NonZeroRational } from './NonZeroRational';
import * as EQ from 'fp-ts/Eq';
import * as ORD from 'fp-ts/Ord';
export declare type Rational = [Integer, Natural];
export declare function fromInteger(x: Integer): Rational;
export declare function isZero(x: Rational): boolean;
export declare function reduce(n: Integer, d: Natural): Rational;
export declare function add([nx, dx]: Rational, [ny, dy]: Rational): Rational;
export declare const zero: Rational;
export declare function mul(x: Rational, y: Rational): Rational;
export declare const one: Rational;
export declare function negate(x: Rational): Rational;
export declare function sub(x: Rational, y: Rational): Rational;
export declare function div(x: Rational, y: NonZeroRational): Rational;
export declare function sign(x: Rational): -1 | 0 | 1;
export declare function floor(x: Rational): Integer;
export declare function round(x: Rational): Integer;
export declare function ceil(x: Rational): Integer;
export declare function trunc(x: Rational): Integer;
export declare const Eq: EQ.Eq<Rational>;
export declare const Ord: ORD.Ord<Rational>;
export declare const show: (x: Rational) => string;