Package de.tilman_neumann.jml.base
Class BigIntConverter
- java.lang.Object
-
- de.tilman_neumann.jml.base.BigIntConverter
-
public class BigIntConverter extends Object
Conversion from doubles to BigInteger with minimal precision loss and no need of slow BigDecimal.- Author:
- Tilman Neumann
- See Also:
- https://de.wikipedia.org/wiki/IEEE_754#Allgemeines
-
-
Constructor Summary
Constructors Constructor Description BigIntConverter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigInteger
fromDouble(double d)
Create a BigInteger from double, with minimal precision loss.static BigInteger
fromDoubleMulPow2(double d, int e2)
Compute BigInteger from double multiplied with a power of 2, i.e.static void
main(String[] args)
-
-
-
Method Detail
-
fromDouble
public static BigInteger fromDouble(double d)
Create a BigInteger from double, with minimal precision loss.- Parameters:
d
-- Returns:
- BigInteger
-
fromDoubleMulPow2
public static BigInteger fromDoubleMulPow2(double d, int e2)
Compute BigInteger from double multiplied with a power of 2, i.e. result ~ d * 2^e2, with minimal precision loss.- Parameters:
d
-e2
-- Returns:
- a BigInteger with approximate value d * 2^e2
-
main
public static void main(String[] args)
-
-