1 | import type { BigNumberish, BytesLike, Numeric } from "./index.js";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export type FixedFormat = number | string | {
|
23 | signed?: boolean;
|
24 | width?: number;
|
25 | decimals?: number;
|
26 | };
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | export declare class FixedNumber {
|
63 | #private;
|
64 | |
65 |
|
66 |
|
67 | readonly format: string;
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 | readonly _value: string;
|
74 | |
75 |
|
76 |
|
77 | constructor(guard: any, value: bigint, format: any);
|
78 | /**
|
79 | * If true, negative values are permitted, otherwise only
|
80 | * positive values and zero are allowed.
|
81 | */
|
82 | get signed(): boolean;
|
83 | /**
|
84 | * The number of bits available to store the value.
|
85 | */
|
86 | get width(): number;
|
87 | /**
|
88 | * The number of decimal places in the fixed-point arithment field.
|
89 | */
|
90 | get decimals(): number;
|
91 | /**
|
92 | * The value as an integer, based on the smallest unit the
|
93 | * [[decimals]] allow.
|
94 | */
|
95 | get value(): bigint;
|
96 | /**
|
97 | * Returns a new [[FixedNumber]] with the result of %%this%% added
|
98 | * to %%other%%, ignoring overflow.
|
99 | */
|
100 | addUnsafe(other: FixedNumber): FixedNumber;
|
101 | /**
|
102 | * Returns a new [[FixedNumber]] with the result of %%this%% added
|
103 | * to %%other%%. A [[NumericFaultError]] is thrown if overflow
|
104 | * occurs.
|
105 | */
|
106 | add(other: FixedNumber): FixedNumber;
|
107 | /**
|
108 | * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
109 | * from %%this%%, ignoring overflow.
|
110 | */
|
111 | subUnsafe(other: FixedNumber): FixedNumber;
|
112 | /**
|
113 | * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
114 | * from %%this%%. A [[NumericFaultError]] is thrown if overflow
|
115 | * occurs.
|
116 | */
|
117 | sub(other: FixedNumber): FixedNumber;
|
118 | /**
|
119 | * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
120 | * by %%other%%, ignoring overflow and underflow (precision loss).
|
121 | */
|
122 | mulUnsafe(other: FixedNumber): FixedNumber;
|
123 | /**
|
124 | * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
125 | * by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
126 | * occurs.
|
127 | */
|
128 | mul(other: FixedNumber): FixedNumber;
|
129 | /**
|
130 | * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
131 | * by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
132 | * occurs or if underflow (precision loss) occurs.
|
133 | */
|
134 | mulSignal(other: FixedNumber): FixedNumber;
|
135 | /**
|
136 | * Returns a new [[FixedNumber]] with the result of %%this%% divided
|
137 | * by %%other%%, ignoring underflow (precision loss). A
|
138 | * [[NumericFaultError]] is thrown if overflow occurs.
|
139 | */
|
140 | divUnsafe(other: FixedNumber): FixedNumber;
|
141 | /**
|
142 | * Returns a new [[FixedNumber]] with the result of %%this%% divided
|
143 | * by %%other%%, ignoring underflow (precision loss). A
|
144 | * [[NumericFaultError]] is thrown if overflow occurs.
|
145 | */
|
146 | div(other: FixedNumber): FixedNumber;
|
147 | /**
|
148 | * Returns a new [[FixedNumber]] with the result of %%this%% divided
|
149 | * by %%other%%. A [[NumericFaultError]] is thrown if underflow
|
150 | * (precision loss) occurs.
|
151 | */
|
152 | divSignal(other: FixedNumber): FixedNumber;
|
153 | /**
|
154 | * Returns a comparison result between %%this%% and %%other%%.
|
155 | *
|
156 | * This is suitable for use in sorting, where ``-1`` implies %%this%%
|
157 | * is smaller, ``1`` implies %%this%% is larger and ``0`` implies
|
158 | * both are equal.
|
159 | */
|
160 | cmp(other: FixedNumber): number;
|
161 | /**
|
162 | * Returns true if %%other%% is equal to %%this%%.
|
163 | */
|
164 | eq(other: FixedNumber): boolean;
|
165 | /**
|
166 | * Returns true if %%other%% is less than to %%this%%.
|
167 | */
|
168 | lt(other: FixedNumber): boolean;
|
169 | /**
|
170 | * Returns true if %%other%% is less than or equal to %%this%%.
|
171 | */
|
172 | lte(other: FixedNumber): boolean;
|
173 | /**
|
174 | * Returns true if %%other%% is greater than to %%this%%.
|
175 | */
|
176 | gt(other: FixedNumber): boolean;
|
177 | /**
|
178 | * Returns true if %%other%% is greater than or equal to %%this%%.
|
179 | */
|
180 | gte(other: FixedNumber): boolean;
|
181 | /**
|
182 | * Returns a new [[FixedNumber]] which is the largest **integer**
|
183 | * that is less than or equal to %%this%%.
|
184 | *
|
185 | * The decimal component of the result will always be ``0``.
|
186 | */
|
187 | floor(): FixedNumber;
|
188 | /**
|
189 | * Returns a new [[FixedNumber]] which is the smallest **integer**
|
190 | * that is greater than or equal to %%this%%.
|
191 | *
|
192 | * The decimal component of the result will always be ``0``.
|
193 | */
|
194 | ceiling(): FixedNumber;
|
195 | /**
|
196 | * Returns a new [[FixedNumber]] with the decimal component
|
197 | * rounded up on ties at %%decimals%% places.
|
198 | */
|
199 | round(decimals?: number): FixedNumber;
|
200 | /**
|
201 | * Returns true if %%this%% is equal to ``0``.
|
202 | */
|
203 | isZero(): boolean;
|
204 | /**
|
205 | * Returns true if %%this%% is less than ``0``.
|
206 | */
|
207 | isNegative(): boolean;
|
208 | /**
|
209 | * Returns the string representation of %%this%%.
|
210 | */
|
211 | toString(): string;
|
212 | /**
|
213 | * Returns a float approximation.
|
214 | *
|
215 | * Due to IEEE 754 precission (or lack thereof), this function
|
216 | * can only return an approximation and most values will contain
|
217 | * rounding errors.
|
218 | */
|
219 | toUnsafeFloat(): number;
|
220 | /**
|
221 | * Return a new [[FixedNumber]] with the same value but has had
|
222 | * its field set to %%format%%.
|
223 | *
|
224 | * This will throw if the value cannot fit into %%format%%.
|
225 | */
|
226 | toFormat(format: FixedFormat): FixedNumber;
|
227 | /**
|
228 | * Creates a new [[FixedNumber]] for %%value%% divided by
|
229 | * %%decimal%% places with %%format%%.
|
230 | *
|
231 | * This will throw a [[NumericFaultError]] if %%value%% (once adjusted
|
232 | * for %%decimals%%) cannot fit in %%format%%, either due to overflow
|
233 | * or underflow (precision loss).
|
234 | */
|
235 | static fromValue(_value: BigNumberish, _decimals?: Numeric, _format?: FixedFormat): FixedNumber;
|
236 | /**
|
237 | * Creates a new [[FixedNumber]] for %%value%% with %%format%%.
|
238 | *
|
239 | * This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
240 | * in %%format%%, either due to overflow or underflow (precision loss).
|
241 | */
|
242 | static fromString(_value: string, _format?: FixedFormat): FixedNumber;
|
243 | /**
|
244 | * Creates a new [[FixedNumber]] with the big-endian representation
|
245 | * %%value%% with %%format%%.
|
246 | *
|
247 | * This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
248 | * in %%format%% due to overflow.
|
249 | */
|
250 | static fromBytes(_value: BytesLike, _format?: FixedFormat): FixedNumber;
|
251 | }
|
252 | //# sourceMappingURL=fixednumber.d.ts.map |
\ | No newline at end of file |