Skip to content

Overflow when encoding a big integer #9

Description

@tdzl2003

When I encode a big integer(bigger than 2^31), it overflow and got a negative value in Node.js

This is because parseInt doesn't limit integer value in 32bit:

> parseInt(12345678901234)
12345678901234

Change the line:

var intVal = parseInt(val);

into:

var intVal = val | 0;

will solve this problem.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions