Skip to content

[JS] Easier way to work with decimals #100

@asfimport

Description

@asfimport

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 / @domoritz

Note: This issue was originally created as ARROW-13099. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions