Skip to content

Commit b9ea5cf

Browse files
peco-engineer-bot[bot]vuanhphung
authored andcommitted
engineer-bot: address @mention on PR #633
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 65806c0 commit b9ea5cf

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎lib/result/ArrowResultConverter.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ export function bigNumDecimalToString(unscaled: bigint, scale: number): string {
192192
return `${negative ? '-' : ''}${digits.slice(0, cut)}.${digits.slice(cut)}`;
193193
}
194194

195+
/**
196+
* Returns the unscaled value of an Arrow Decimal128 as a number.
197+
*
198+
* Decimal128 is four little-endian 32-bit words. If words 2–3 are pure sign
199+
* extension of word 1, the unscaled value fits in an int64, and we return it
200+
* directly when it's a safe integer; otherwise fall back to `bigNumToBigInt`.
201+
*/
195202
function decimalToNumber(value: Uint32Array & Parameters<typeof bigNumToBigInt>[0]): number {
196203
if (value.length === 4) {
197204
const high = value[1] | 0;

0 commit comments

Comments
 (0)