bigfloat.js
Version:
A library for arbitrary precision floating point arithmetic.
26 lines (25 loc) • 752 B
JavaScript
import JSBI from "jsbi";
import { BIGINT_ZERO } from "./constants.js";
import { integer } from "./constructors.js";
import { eq } from "./relational.js";
export function is_big_float(big) {
return (typeof big === "object"
&& !(big instanceof JSBI)
&& big.coefficient instanceof JSBI
&& Number.isSafeInteger(big.exponent));
}
export function is_number(token) {
return !Number.isNaN(Number(token));
}
export function is_negative(big) {
return JSBI.LT(big.coefficient, BIGINT_ZERO);
}
export function is_positive(big) {
return JSBI.GE(big.coefficient, BIGINT_ZERO);
}
export function is_zero(big) {
return JSBI.EQ(big.coefficient, BIGINT_ZERO);
}
export function is_integer(a) {
return eq(a, integer(a));
}