strint icon indicating copy to clipboard operation
strint copied to clipboard

Multiply error and errors with "0"

Open timo22345 opened this issue 13 years ago • 7 comments
trafficstars

strint.mul ("69226", "90739") gives "6279698014". Should be "6281498014".

strint.mul ("676", "-162252177270612080800354289") gives "-73682471834573766620859493964". Should be "-109682471834933766621039499364".

And several other multiplys fails.

strint.mul ("-5058219","0") gives "-". Should be "0".

strint.mul ("0","0") gives "". Should be "0".

string.add("0","0") gives "". Should be "0". string.sub("0","0") gives "". Should be "0".

strint.div("10","0") makes browser hang. Should return "Division by zero error".

timo22345 avatar Nov 23 '12 06:11 timo22345

Also strint.mul("2","256"); --> 422 strint.mul("256","2"); --> 512

strint.mul("2","512 "); --> 124 strint.mul("512 ","2"); --> 124

VERY experimental code :\

axtens avatar Mar 31 '14 05:03 axtens

Yes, this is why the readme starts with “Experimental code – beware”. It is a proof of concept, neither efficient nor bug-free.

Thanks for reporting the bugs, though! I will (eventually) add them to the unit tests.

rauschma avatar Mar 31 '14 09:03 rauschma

Here's a whole bunch of examples not working :(

https://jsfiddle.net/8vzo2fgw/7/

thedavidmeister avatar May 19 '15 14:05 thedavidmeister

I think I may have fixed the weird multiplying results with Pull Request #5. At least the first few examples in the original comment work now.

calebsander avatar Jun 27 '15 04:06 calebsander

@calebsander Great work. I've confirmed your branch fixes my failing case: 3844 X 27

adambullmer avatar May 21 '16 07:05 adambullmer

Hello, all. :) Just adding one more test case for the forthcoming suite. This one is multiplication error.

console.log(strint.mul(String(14159572), String(63967072))); //905745461613184
console.log(+bigNum(14159572).multiply(63967072)); // 905746361613184

Library big-number is provided for reference.

alexeykomov avatar Sep 12 '16 10:09 alexeykomov

My branch (see #5) fixes your issue. I don't believe this repository is being maintained any longer.

calebsander avatar Sep 12 '16 22:09 calebsander