@xylabs/decimal-precision 5.0.84 → 5.0.86
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/README.md +22 -39
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
## Reference
|
|
19
21
|
|
|
20
22
|
**@xylabs/decimal-precision**
|
|
@@ -23,9 +25,11 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
23
25
|
|
|
24
26
|
## Functions
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
| Function | Description |
|
|
29
|
+
| ------ | ------ |
|
|
30
|
+
| [fromFixedPoint](#functions/fromFixedPoint) | Converts a fixed-point bigint back to a whole-number bigint by dividing out the decimal places. |
|
|
31
|
+
| [toDecimalPrecision](#functions/toDecimalPrecision) | Formats a number to the specified number of significant digits, returning a string with minimal trailing zeros. |
|
|
32
|
+
| [toFixedPoint](#functions/toFixedPoint) | Converts a bigint or decimal string to a fixed-point bigint representation. |
|
|
29
33
|
|
|
30
34
|
### functions
|
|
31
35
|
|
|
@@ -36,24 +40,17 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
36
40
|
***
|
|
37
41
|
|
|
38
42
|
```ts
|
|
39
|
-
function fromFixedPoint(value, places
|
|
43
|
+
function fromFixedPoint(value: bigint, places?: number): bigint;
|
|
40
44
|
```
|
|
41
45
|
|
|
42
46
|
Converts a fixed-point bigint back to a whole-number bigint by dividing out the decimal places.
|
|
43
47
|
|
|
44
48
|
## Parameters
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`bigint`
|
|
49
|
-
|
|
50
|
-
The fixed-point bigint value to convert
|
|
51
|
-
|
|
52
|
-
### places?
|
|
53
|
-
|
|
54
|
-
`number` = `18`
|
|
55
|
-
|
|
56
|
-
Number of decimal places (default 18)
|
|
50
|
+
| Parameter | Type | Default value | Description |
|
|
51
|
+
| ------ | ------ | ------ | ------ |
|
|
52
|
+
| `value` | `bigint` | `undefined` | The fixed-point bigint value to convert |
|
|
53
|
+
| `places` | `number` | `18` | Number of decimal places (default 18) |
|
|
57
54
|
|
|
58
55
|
## Returns
|
|
59
56
|
|
|
@@ -68,24 +65,17 @@ The whole-number bigint result
|
|
|
68
65
|
***
|
|
69
66
|
|
|
70
67
|
```ts
|
|
71
|
-
function toDecimalPrecision(value, digits): string;
|
|
68
|
+
function toDecimalPrecision(value: number, digits: number): string;
|
|
72
69
|
```
|
|
73
70
|
|
|
74
71
|
Formats a number to the specified number of significant digits, returning a string with minimal trailing zeros.
|
|
75
72
|
|
|
76
73
|
## Parameters
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
`number`
|
|
81
|
-
|
|
82
|
-
The number to format
|
|
83
|
-
|
|
84
|
-
### digits
|
|
85
|
-
|
|
86
|
-
`number`
|
|
87
|
-
|
|
88
|
-
The number of significant digits
|
|
75
|
+
| Parameter | Type | Description |
|
|
76
|
+
| ------ | ------ | ------ |
|
|
77
|
+
| `value` | `number` | The number to format |
|
|
78
|
+
| `digits` | `number` | The number of significant digits |
|
|
89
79
|
|
|
90
80
|
## Returns
|
|
91
81
|
|
|
@@ -100,24 +90,17 @@ A string representation of the number with the specified precision
|
|
|
100
90
|
***
|
|
101
91
|
|
|
102
92
|
```ts
|
|
103
|
-
function toFixedPoint(value, places
|
|
93
|
+
function toFixedPoint(value: string | bigint, places?: number): bigint;
|
|
104
94
|
```
|
|
105
95
|
|
|
106
96
|
Converts a bigint or decimal string to a fixed-point bigint representation.
|
|
107
97
|
|
|
108
98
|
## Parameters
|
|
109
99
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
The value to convert (bigint or string with optional decimal point)
|
|
113
|
-
|
|
114
|
-
`string` | `bigint`
|
|
115
|
-
|
|
116
|
-
### places?
|
|
117
|
-
|
|
118
|
-
`number` = `18`
|
|
119
|
-
|
|
120
|
-
Number of decimal places (default 18)
|
|
100
|
+
| Parameter | Type | Default value | Description |
|
|
101
|
+
| ------ | ------ | ------ | ------ |
|
|
102
|
+
| `value` | `string` \| `bigint` | `undefined` | The value to convert (bigint or string with optional decimal point) |
|
|
103
|
+
| `places` | `number` | `18` | Number of decimal places (default 18) |
|
|
121
104
|
|
|
122
105
|
## Returns
|
|
123
106
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/decimal-precision",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.86",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"decimal",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"!**/*.test.*"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@xylabs/ts-scripts-yarn3": "~7.4.
|
|
47
|
-
"@xylabs/tsconfig": "~7.4.
|
|
46
|
+
"@xylabs/ts-scripts-yarn3": "~7.4.16",
|
|
47
|
+
"@xylabs/tsconfig": "~7.4.16",
|
|
48
48
|
"typescript": "~5.9.3",
|
|
49
49
|
"vitest": "~4.0.18"
|
|
50
50
|
},
|