dartist / dart-bignum

Other
14 stars 11 forks source link

bitwise operators dont have desired results when compiled to javascript #3

Open adam-singer opened 12 years ago

adam-singer commented 12 years ago

dart2js does not carry the signed bit when code is compiled to javascript that uses the shift operators << >> . This leads to bugs with the way bit shifting is implemented with native dart int.

ltackmann commented 12 years ago

Are these bugs contained to shifting operations on BigNum or are they also apparent when doing ordinary math with bignums (which also internally rely on shifting) ?

adam-singer commented 12 years ago

I think its only when shifting numbers that are negative the object fails. Internally none of numbers in the internal data structure should be negative, so all computations should be safe. I noticed this issue when dealing with negative numbers and put a safe guard in for checking a shift on negative carry http://goo.gl/Ayjnv . While I dont like this solution at the moment, it seems to work.

adam-singer commented 12 years ago

google group discussion started on this https://groups.google.com/a/dartlang.org/d/topic/misc/3olrB-Fkd5U/discussion