@lvlte/ulp 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +2 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -6
- package/package.json +3 -6
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const FLOAT64_MIN: number;
|
|
|
5
5
|
/**
|
|
6
6
|
* Return the unit in the last place or unit of least precision (ulp) of x, that
|
|
7
7
|
* is, the distance between two consecutive representable floating-point numbers
|
|
8
|
-
* at x.
|
|
8
|
+
* at x. If x is a power of 2, the distance on either side of x is different, in
|
|
9
|
+
* which case the larger distance is returned.
|
|
9
10
|
*
|
|
10
11
|
* @param x The input number (default: 1)
|
|
11
12
|
* @returns The ulp of x, or `NaN` if `x` is not a finite number.
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ulp = exports.FLOAT64_MIN = void 0;
|
|
4
4
|
exports.eps = eps;
|
|
5
5
|
exports.exponent = exponent;
|
|
6
|
-
const modf_1 = require("@lvlte/modf");
|
|
7
6
|
exports.FLOAT64_MIN = Math.pow(2, -1022);
|
|
8
7
|
function eps(x = 1) {
|
|
9
8
|
if (Number.isFinite(x)) {
|
|
@@ -23,9 +22,6 @@ function exponent(x) {
|
|
|
23
22
|
return NaN;
|
|
24
23
|
}
|
|
25
24
|
function _exponent(x) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return ipart.toString(2).split('.', 1)[0].length - 1;
|
|
29
|
-
}
|
|
30
|
-
return -(fpart.toString(2).split('1', 1)[0].length - 1);
|
|
25
|
+
const s = x.toString(2);
|
|
26
|
+
return x < 1 ? -(s.split('1', 1)[0].length - 1) : s.split('.', 1)[0].length - 1;
|
|
31
27
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const FLOAT64_MIN: number;
|
|
|
5
5
|
/**
|
|
6
6
|
* Return the unit in the last place or unit of least precision (ulp) of x, that
|
|
7
7
|
* is, the distance between two consecutive representable floating-point numbers
|
|
8
|
-
* at x.
|
|
8
|
+
* at x. If x is a power of 2, the distance on either side of x is different, in
|
|
9
|
+
* which case the larger distance is returned.
|
|
9
10
|
*
|
|
10
11
|
* @param x The input number (default: 1)
|
|
11
12
|
* @returns The ulp of x, or `NaN` if `x` is not a finite number.
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { modf } from '@lvlte/modf';
|
|
2
1
|
export const FLOAT64_MIN = Math.pow(2, -1022);
|
|
3
2
|
export function eps(x = 1) {
|
|
4
3
|
if (Number.isFinite(x)) {
|
|
@@ -18,9 +17,6 @@ export function exponent(x) {
|
|
|
18
17
|
return NaN;
|
|
19
18
|
}
|
|
20
19
|
function _exponent(x) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
return ipart.toString(2).split('.', 1)[0].length - 1;
|
|
24
|
-
}
|
|
25
|
-
return -(fpart.toString(2).split('1', 1)[0].length - 1);
|
|
20
|
+
const s = x.toString(2);
|
|
21
|
+
return x < 1 ? -(s.split('1', 1)[0].length - 1) : s.split('.', 1)[0].length - 1;
|
|
26
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvlte/ulp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Compute the unit in last place of a given IEEE-754 64-bit number",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Lavault <lvlte.code@gmail.com>",
|
|
@@ -52,15 +52,12 @@
|
|
|
52
52
|
"ULP"
|
|
53
53
|
],
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@lvlte/tsconfig": "^1.0
|
|
55
|
+
"@lvlte/tsconfig": "^1.1.0",
|
|
56
56
|
"@types/jest": "^29.5.12",
|
|
57
57
|
"jest": "^29.7.0",
|
|
58
58
|
"make-dir-cli": "^4.0.0",
|
|
59
59
|
"rimraf": "^6.0.1",
|
|
60
60
|
"ts-jest": "29.2.5",
|
|
61
|
-
"typescript": "^5.9.
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"@lvlte/modf": "^1.1.0"
|
|
61
|
+
"typescript": "^5.9.3"
|
|
65
62
|
}
|
|
66
63
|
}
|