apache / apache/arrow-js

[JS] Easier way to work with decimals

Open
#100 0 comments 1 reaction 0 assignees View on GitHub
Type: enhancement
Dominant language
TypeScript
Stars
112
Forks
23
Avg merge
21h 18m
Merged PRs (30d)
8

Description

I have table with a column, let’s call the column c. c.type returns Decimal {scale: 3, precision: 12}. c.get(0) returns [519500, 0, 0, 0]. I know the value should be 519.5. After much digging, I found that the value is actually an arrow “big number” (https://github.com/apache/arrow/blob/ccdbbe3b765d4df9b2b91270a69ad78a086f2d77/js/src/util/bn.ts), so it has a valueOf function which returns 519500 (with the obvious caveat that it’ll overflow if the number is more than 53-bits). I could divide that by 10^scale from c.type to get 519.5. Is there some easier way to do that?

Filed by bmatcuk@gmail.com

**Reporter**: [Dominik Moritz](https://issues.apache.org/jira/browse/ARROW-13099) / @domoritz

**Note**: *This issue was originally created as [ARROW-13099](https://issues.apache.org/jira/browse/ARROW-13099). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.