You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Dominik Moritz (Jira)" <ji...@apache.org> on 2021/06/16 18:16:00 UTC

[jira] [Updated] (ARROW-13099) [JS] Easier way to work with decimals

     [ https://issues.apache.org/jira/browse/ARROW-13099?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dominik Moritz updated ARROW-13099:
-----------------------------------
    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

  was: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?


> [JS] Easier way to work with decimals
> -------------------------------------
>
>                 Key: ARROW-13099
>                 URL: https://issues.apache.org/jira/browse/ARROW-13099
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: JavaScript
>            Reporter: Dominik Moritz
>            Priority: Major
>
> 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



--
This message was sent by Atlassian Jira
(v8.3.4#803005)