Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fromString with a string that isn't an integer behaves weird #123

Open
parbo opened this issue Jun 9, 2023 · 0 comments
Open

fromString with a string that isn't an integer behaves weird #123

parbo opened this issue Jun 9, 2023 · 0 comments

Comments

@parbo
Copy link

parbo commented Jun 9, 2023

var Long = require("long");
var s = Long.fromString(String(1.1 * 100));
console.log("Long.fromString(..):", s);
console.log("Long.toString(..):", s.toString());

Outputs:

Long.fromString(..): Long { low: 488372225, high: 256, unsigned: false }
Long.toString(..): 1100000000001

Another example:

var Long = require("long");
var s = Long.fromString("123 7 8 9");
console.log("Long.fromString(..):", s);
console.log("Long.toString(..):", s.toString());

Outputs:

Long.fromString(..): Long { low: 1239, high: 0, unsigned: false }
Long.toString(..): 1239

I'd expect both of these to throw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant