DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

LongMath.checkedPow() mishandles negative numbers with large magnitude #1624

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In v15, LongMath.checkPow(Long.MIN_VALUE,2)==0.  Instead, it should throw an 
ArithmeticException per specification.  The problem occurs more generally when 
the base is negative and the result overflows.

LongMath's checkPow() implementation should have the similar check as IntMath:

// from LongMath.checkedPow()
checkNoOverflow(b <= FLOOR_SQRT_MAX_LONG); 

// from IntMath.checkedPow()
checkNoOverflow(-FLOOR_SQRT_MAX_INT <= b & b <= FLOOR_SQRT_MAX_INT); 

Original issue reported on code.google.com by jiho...@gmail.com on 27 Dec 2013 at 11:08

GoogleCodeExporter commented 9 years ago

Original comment by kak@google.com on 28 Dec 2013 at 12:58

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08