bigint, biginteger throw on double values outside of long range

Description

The bigint and biginteger functions throw on double values outside of long range

This works fine:

but passing any Float or Double values outside the range of a long throw an exception:

Cause: bigint and biginteger cover a series of possible input cases but did not have an explicit case for Float or Double, so was falling back to default.

Solution: Add check for Float/Double case that coerces the input to double, then uses BigDecimal.valueOf(), then converts to a BigInteger and so on as with other types.

Patch: clj-1197-make-bigint-work-on-all-doubles-v1.txt

Environment

None

Attachments

1

Activity

Show:

Alex Miller August 8, 2013 at 7:51 AM

Cleaned up the description a bit.

cldwalker May 17, 2013 at 4:52 PM

Looks good. Tests pass and the failing example now converts correctly

Andy Fingerhut April 7, 2013 at 10:38 PM

Patch clj-1197-make-bigint-work-on-all-doubles-v1.txt dated Apr 7 2013 changes bigint and biginteger so that they return the correct value for all float and double values, and no longer throw an exception.

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Fix versions

Created April 7, 2013 at 10:35 PM
Updated August 15, 2013 at 12:13 AM
Resolved August 15, 2013 at 12:13 AM