Skip to content

Decimal conversion in value-parser.js has problems with DECIMAL(38,20) #760

Open

Description

@jacopotrentin96

Reading from a stored procedure a field DECIMAL(38,20) returns some wrong numbers due to wrong parsing of the value.

EX: Number 1000 will be returned as 999.9999999999999....

Using the library Decimal.js https://github.com/MikeMcl/decimal.js/
and substituting the row 304 of value-parser.js ( callback(value * sign / Math.pow(10, metaData.scale)); )
with

var v = new Decimal(value); 
               var s = new Decimal(sign);
               var sc = new Decimal(10).pow(metaData.scale);
               var res = v.mul(s).div(sc);
               callback(res.toNumber());

solves the problem.

Activity

  1. Suraiya-Hameed commented on Jul 3, 2018

    @Suraiya-Hameed
    Member

    Linking #678

  2. added
    known issue
    on Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    known issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions