Skip to content

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

Closed as not planned
@parbo

Description

@parbo
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions