0

C#/.NET has the BigInteger class that provides methods for exponentiation and logarithms on arbitrary precision integers.

public static double Log (System.Numerics.BigInteger value);

public static double Log (System.Numerics.BigInteger value);

public static System.Numerics.BigInteger Pow (System.Numerics.BigInteger value, int exponent);

How does one compute BigInteger.Pow(x, y) where y is a float or double type? It looks like there is no built-in method in the class library. Is there an algorithm one can implement for this?

vvg
  • 1,010
  • 7
  • 25

1 Answers1

0

You can rewrite something like this :

public class something
{
    public static void Test()
    {
        int @base = 10;
        double exp = 12345.123;
        int intExp = (int)Math.Floor(exp);
        double fracExp = exp - intExp;
        BigInteger temp = BigInteger.Pow(@base, intExp);
        double temp2 = Math.Pow(@base, fracExp);
        int fractionBitsForDouble = 52;
        for (int i = 0; i < fractionBitsForDouble; i++)
        {
            temp = BigInteger.Divide(temp, 2);
            temp2 *= 2;
        }

        BigInteger result = BigInteger.Multiply(temp, (BigInteger)temp2);

        Console.WriteLine(result);
    }
}
SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139
  • 1
    U can refer here its already answered https://stackoverflow.com/questions/11179289/how-to-get-the-biginteger-to-the-pow-double-in-c – SmartestVEGA Sep 17 '22 at 07:11