### HridoyHazard's blog

By HridoyHazard, history, 11 days ago,

i came to know this error recently while using pow function for a large data such as

pow(8376260,70)

it giving 0 as output which is wrong. i tried using long and unsigned but it giving the same output. is there any way to use large data in pow function??

• -4

 » 11 days ago, # | ← Rev. 2 →   0 Yeah this function is kinda weird so it does problems. Create your own pow function so it doesn't cause problems. Also the numbers you are using are very large so it will overflow
•  » » 11 days ago, # ^ |   0 The function is fine, it even reports errors when it happens. You can check such errors with the errno macro.
•  » » » 11 days ago, # ^ |   0 Thanks. I never lnew that. But isn't implementing the function yourself better? Especially when you have to do it for large numbers where you have to use mod
•  » » » » 11 days ago, # ^ |   0 yep, in this case that would probably be the only option.(unless you're using python, of course)
 » 11 days ago, # |   0 the pow function returns a "double" type.
 » 11 days ago, # |   0 https://www.youtube.com/watch?v=L-Wzglnm4dM : This video will solve all of your problems regarding powers.
 » 11 days ago, # |   +1 You'd better use binary pow. const long long MOD = 1e9 + 7; long long binpow(long long n, long long p){ long long res = 1; while(p) { if(p & 1) { res *= n; res %= MOD; } p >>= 1; n *= n; n %= MOD; } return res; }