Class BigIntConverter

java.lang.Object
de.tilman_neumann.jml.base.BigIntConverter

public class BigIntConverter
extends java.lang.Object
Conversion from doubles to BigInteger with minimal precision loss and no need of slow BigDecimal.
See Also:
https://de.wikipedia.org/wiki/IEEE_754#Allgemeines
  • Constructor Summary

    Constructors
    Constructor Description
    BigIntConverter()  
  • Method Summary

    Modifier and Type Method Description
    static java.math.BigInteger fromDouble​(double d)
    Create a BigInteger from double, with minimal precision loss.
    static java.math.BigInteger fromDoubleMulPow2​(double d, int e2)
    Compute BigInteger from double multiplied with a power of 2, i.e.
    static void main​(java.lang.String[] args)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BigIntConverter

      public BigIntConverter()
  • Method Details

    • fromDouble

      public static java.math.BigInteger fromDouble​(double d)
      Create a BigInteger from double, with minimal precision loss.
      Parameters:
      d -
      Returns:
      BigInteger
    • fromDoubleMulPow2

      public static java.math.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​(java.lang.String[] args)