dartist / dart-bignum

Other
14 stars 11 forks source link

BigInteger.longValue() missing #30

Open stevenroose opened 10 years ago

stevenroose commented 10 years ago

CORRECTION: see first comment

Java's BigInteger has a longValue() getter to return the BigInteger's value as a long.

dart-bignum's only has an intValue(). While Dart does not have a long type, the integer type does support numbers larger than 32 bits. However, the intValue() getter caps the value at 32 bits.

So there should be a longValue() getter that allows for numbers up to 64 bits. Dart supports 64-bit integers and JS also supports ints larger than 32 bits.

I tried to look at it myself, but I don't fully understand the code. (Does the JS BigInteger have a longValue()?)

stevenroose commented 10 years ago

Ok, it seems that the intValue() getter does work as a longValue() getter, but only works for positive values.

Check this:

new BigInteger(-2147483647).intValue() returns to 2147483649

adam-singer commented 10 years ago

@stevenroose was that in javascript or dartvm, or both?

stevenroose commented 10 years ago

That was in dartvm. I did not test in JS On Apr 2, 2014 5:55 AM, "Adam Singer" notifications@github.com wrote:

@stevenroose https://github.com/stevenroose was that in javascript or dartvm, or both?

Reply to this email directly or view it on GitHubhttps://github.com/dartist/dart-bignum/issues/30#issuecomment-39286596 .

adam-singer commented 10 years ago

Would have to think about this more... Dont have a good plan about "fixing" this.