You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create an Decimal data type instance for exact decimal values, represented as a 128 or 256-bit integer value in two's complement. Decimals are fixed point numbers with a set *precision* (total number of decimal digits) and *scale* (number of fractional digits). For example, the number `35.42` can be represented as `3542` with *precision* ≥ 4 and *scale* = 2.
242
+
Create an Decimal data type instance for exact decimal values, represented as a 32, 64, 128, or 256-bit integer value in two's complement. Decimals are fixed point numbers with a set *precision* (total number of decimal digits) and *scale* (number of fractional digits). For example, the number `35.42` can be represented as `3542` with *precision* ≥ 4 and *scale* = 2.
243
243
244
-
By default, Flechette converts decimals to 64-bit floating point numbers upon extraction (e.g., mapping `3542` back to `35.42`). While useful for many downstream applications, this conversion may be lossy and introduce inaccuracies. Pass the `useDecimalBigInt` extraction option (e.g., to [`tableFromIPC`](/flechette/api/#tableFromIPC) or [`tableFromArrays`](/flechette/api/#tableFromArrays)) to instead extract decimal data as `BigInt` values.
244
+
By default, Flechette converts decimals to 64-bit floating point numbers upon extraction (e.g., mapping `3542` back to `35.42`). While useful for many downstream applications, this conversion may be lossy and introduce inaccuracies. Pass the `useDecimalBigInt` extraction option (e.g., to [`tableFromIPC`](/flechette/api/#tableFromIPC) or [`tableFromArrays`](/flechette/api/#tableFromArrays)) to instead extract decimal data as `BigInt` values (64-bit or larger decimals) or integer `number` values (32-bit decimals).
245
245
246
246
**precision* (`number`): The total number of decimal digits that can be represented.
247
247
**scale* (`number`): The number of fractional digits, beyond the decimal point.
248
-
**bitWidth* (`number`): The decimal bit width, one of `128` (default) or `256`.
248
+
**bitWidth* (`number`): The decimal bit width, one of `32`, `64`, `128` (default) or `256`.
249
249
250
250
```js
251
-
import { utf8 } from'@uwdata/flechette';
251
+
import { decimal } from'@uwdata/flechette';
252
252
// decimal with 18 total digits, including 3 fractional digits
Create a Decimal data type instance that uses 32 bits per decimal. 32-bit decimals are stored within an `Int32Array`.
261
+
262
+
**precision* (`number`): The total number of decimal digits that can be represented.
263
+
**scale* (`number`): The number of fractional digits, beyond the decimal point.
264
+
265
+
<hr/><aid="decimal64"href="#decimal64">#</a>
266
+
<b>decimal64</b>(<i>precision</i>, <i>scale</i>)
267
+
268
+
Create a Decimal data type instance that uses 64 bits per decimal. 64-bit decimals are stored within a `Uint64Array`.
269
+
270
+
**precision* (`number`): The total number of decimal digits that can be represented.
271
+
**scale* (`number`): The number of fractional digits, beyond the decimal point.
272
+
273
+
<hr/><aid="decimal128"href="#decimal128">#</a>
274
+
<b>decimal128</b>(<i>precision</i>, <i>scale</i>)
275
+
276
+
Create a Decimal data type instance that uses 128 bits per decimal. 128-bit decimals are stored within a `Uint64Array` with a stride of 2 (two array entries per decimal value).
277
+
278
+
**precision* (`number`): The total number of decimal digits that can be represented.
279
+
**scale* (`number`): The number of fractional digits, beyond the decimal point.
280
+
281
+
<hr/><aid="decimal256"href="#decimal256">#</a>
282
+
<b>decimal256</b>(<i>precision</i>, <i>scale</i>)
283
+
284
+
Create a Decimal data type instance that uses 256 bits per decimal. 256-bit decimals are stored within a `Uint64Array` with a stride of 4 (four array entries per decimal value).
285
+
286
+
**precision* (`number`): The total number of decimal digits that can be represented.
287
+
**scale* (`number`): The number of fractional digits, beyond the decimal point.
0 commit comments