@danielsimonjr/mathts-core 0.13.1 → 0.14.0
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.
|
@@ -914,9 +914,7 @@ function toPrecision(value, precision, options) {
|
|
|
914
914
|
if (precision && c.length < precision) {
|
|
915
915
|
c = c.concat(zeros(precision - c.length));
|
|
916
916
|
}
|
|
917
|
-
c = c.concat(
|
|
918
|
-
zeros(e - c.length + 1 + (precision && c.length < precision ? precision - c.length : 0))
|
|
919
|
-
);
|
|
917
|
+
c = c.concat(zeros(e - c.length + 1));
|
|
920
918
|
c = zeros(-e).concat(c);
|
|
921
919
|
const dot = e > 0 ? e : 0;
|
|
922
920
|
if (dot < c.length - 1) {
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
round,
|
|
45
45
|
sign,
|
|
46
46
|
subtractScalar
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-YZN52XIQ.js";
|
|
48
48
|
|
|
49
49
|
// src/types/matrix/Range.ts
|
|
50
50
|
var name = "Range";
|
|
@@ -1321,7 +1321,7 @@ function neumaierCumsum(xs, out) {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
1323
|
// src/index.ts
|
|
1324
|
-
var VERSION = "0.
|
|
1324
|
+
var VERSION = "0.14.0";
|
|
1325
1325
|
export {
|
|
1326
1326
|
ALL_UNITS,
|
|
1327
1327
|
BASE_UNITS,
|
package/dist/internal.js
CHANGED
|
@@ -78,7 +78,7 @@ import {
|
|
|
78
78
|
typeOf,
|
|
79
79
|
unitDependencies,
|
|
80
80
|
warnOnce
|
|
81
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-YZN52XIQ.js";
|
|
82
82
|
|
|
83
83
|
// src/error/DimensionError.ts
|
|
84
84
|
var DimensionError = class _DimensionError extends RangeError {
|
|
@@ -226,13 +226,31 @@ function format2(value, options) {
|
|
|
226
226
|
return formatBigNumberToBase(v, 16, wordSize);
|
|
227
227
|
case "auto": {
|
|
228
228
|
const optionsObj = options;
|
|
229
|
-
const lowerExp =
|
|
230
|
-
const upperExp =
|
|
229
|
+
const lowerExp = isNumber(optionsObj?.lowerExp) || isBigNumber(optionsObj?.lowerExp) ? optionsObj?.lowerExp : -3;
|
|
230
|
+
const upperExp = isNumber(optionsObj?.upperExp) || isBigNumber(optionsObj?.upperExp) ? optionsObj?.upperExp : 5;
|
|
231
231
|
if (v.isZero()) return "0";
|
|
232
232
|
let str;
|
|
233
233
|
const rounded = v.toSignificantDigits(precision);
|
|
234
234
|
const exp = rounded.e;
|
|
235
|
-
|
|
235
|
+
let condition = false;
|
|
236
|
+
if (isBigNumber(lowerExp) && isBigNumber(upperExp)) {
|
|
237
|
+
const lowerExpBn = lowerExp;
|
|
238
|
+
const upperExpBn = upperExp;
|
|
239
|
+
condition = !lowerExpBn.greaterThan(exp) && upperExpBn.greaterThan(exp);
|
|
240
|
+
} else if (isBigNumber(lowerExp)) {
|
|
241
|
+
const lowerExpBn = lowerExp;
|
|
242
|
+
const upperExpNum = upperExp;
|
|
243
|
+
condition = !lowerExpBn.greaterThan(exp) && exp < upperExpNum;
|
|
244
|
+
} else if (isBigNumber(upperExp)) {
|
|
245
|
+
const upperExpBn = upperExp;
|
|
246
|
+
const lowerExpNum = lowerExp;
|
|
247
|
+
condition = exp >= lowerExpNum && upperExpBn.greaterThan(exp);
|
|
248
|
+
} else {
|
|
249
|
+
const lowerExpNum = lowerExp;
|
|
250
|
+
const upperExpNum = upperExp;
|
|
251
|
+
condition = exp >= lowerExpNum && exp < upperExpNum;
|
|
252
|
+
}
|
|
253
|
+
if (condition) {
|
|
236
254
|
str = rounded.toFixed();
|
|
237
255
|
} else {
|
|
238
256
|
str = toExponential2(v, precision);
|
|
@@ -271,15 +289,6 @@ function toExponential2(value, precision) {
|
|
|
271
289
|
function toFixed2(value, precision) {
|
|
272
290
|
return value.toFixed(precision);
|
|
273
291
|
}
|
|
274
|
-
function _toNumberOrDefault(value, defaultValue) {
|
|
275
|
-
if (isNumber(value)) {
|
|
276
|
-
return value;
|
|
277
|
-
} else if (isBigNumber(value)) {
|
|
278
|
-
return value.toNumber();
|
|
279
|
-
} else {
|
|
280
|
-
return defaultValue;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
292
|
|
|
284
293
|
// src/string.ts
|
|
285
294
|
function format3(value, options) {
|
|
@@ -1024,7 +1033,7 @@ function deepMap2(array, callback, skipZeros) {
|
|
|
1024
1033
|
function reduce(mat, dim, callback) {
|
|
1025
1034
|
const size = Array.isArray(mat) ? arraySize(mat) : mat.size();
|
|
1026
1035
|
if (dim < 0 || dim >= size.length) {
|
|
1027
|
-
throw new
|
|
1036
|
+
throw new DimensionError(dim, size.length, "<");
|
|
1028
1037
|
}
|
|
1029
1038
|
if (isMatrix(mat)) {
|
|
1030
1039
|
const reduced = _reduce(mat.valueOf(), dim, callback);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Core types, utilities, and configuration for MathTS",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "https://github.com/danielsimonjr/
|
|
51
|
+
"url": "git+https://github.com/danielsimonjr/MathTS.git",
|
|
52
52
|
"directory": "core"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|