Custom Float Power Function

Hello, I am trying to make a custom floating point power function of some sort. I need to do this because I am using a bignum library that lets me declare integers and floats with any number of bits I want, and I am dealing with very big numbers. I have absolutely now idea how to make a power function for this; I'm good at math, and OK at programming, but I can't get the two to mesh. I have done a lot of searching but I cannot find anything that will work correctly or accurately when I implement it. The bignum lib I use supports most things except for the power operators (^=, ^) and the modulo operators (%=, %) for floating point types.

If someone could set me on the right track for making a function for a super-big, super-accurate floating point power function, I'd highly appreciate it.

Thanks,
-LB
Are you looking for modpow operations?

I found this project about big integers in c++. I don't know if they implement correctly the modpow algorithm, but worth trying.

The bad news is there isn't documentation :(

https://mattmccutchen.net/bigint/
No, I want something that allows me to take a float as a base, and raise it to a float as the power, and return a float. I can't use any of the inbuilt C++ power functions because I have no source to them to change for my big float types. I was simply saying what the lib was capable of when I mentioned the modulo operators. (The lib is not finished but I was hoping to use a workaround for it until it was finished)
Sorry, I don't really have an answer for you, but
super-big, super-accurate floating point
if you don't want to sound like a complete tool, I suggest you use the term "arbitrary precision".
I was literally using the name of the type of variable defined by the library. It's literally called "BigInt" and such.
If the exponent is an integer you can use divide and conquer a^n = a^(n/2) * a^(n/2)

For float exponent, maybe this X^Y = e^(ln(X^Y)) = e^(Y*ln(X))
Could you explain the floating point one more? I'm not sure which of those variables are integers and which are floating point types.
You should drop your current bignum library and use gmp instead.
GMP doesn't work for me because my compiler always complains about it being in 'mac format" or whatever.
Then download the appropriate version for your platform.
If the exponent is an integer you can use divide and conquer a^n = a^(n/2) * a^(n/2)
What? If n is an integer, you can just multiply a by itself n times. What are you talking about divide an conquer?
Last edited on
What? If n is an integer, you can just multiply a by itself n times. What are you talking about divide an conquer?

That will be O(n). Divide and conquer is O(log n).
If the number has a lot of digits the multiplication will cost you.
Then download the appropriate version for your platform.


There are only two download links for GNP and both are in this "Mac Format". :(
Topic archived. No new replies allowed.