isSafeInteger: isSafeIntegralNumber,
} = Number;
+/** Positive zero. */
+export const POSITIVE_ZERO = 0;
+
+/** Negative zero. */
+export const NEGATIVE_ZERO = -0;
+
/**
* Returns the magnitude (absolute value) of the provided value.
*
? n === 0n ? 0n : n < 0n ? -1n : 1n
: isNan(n) || n === 0
? n
- : //deno-lint-ignore no-compare-neg-zero
- n < -0
- ? -1
- : 1;
+ //deno-lint-ignore no-compare-neg-zero
+ : n < -0
+ ? -1
+ : 1;
};
/**
clz32,
max,
min,
+ NEGATIVE_ZERO,
+ POSITIVE_ZERO,
sgn,
toBigInt,
toFloat32,
toUintN,
} from "./numeric.js";
+describe("NEGATIVE_ZERO", () => {
+ it("[[Get]] is negative zero", () => {
+ assertStrictEquals(NEGATIVE_ZERO, -0);
+ });
+});
+
+describe("POSITIVE_ZERO", () => {
+ it("[[Get]] is positive zero", () => {
+ assertStrictEquals(POSITIVE_ZERO, 0);
+ });
+});
+
describe("abs", () => {
it("[[Call]] returns the absolute value", () => {
assertStrictEquals(abs(-1), 1);