#How to avoid pow() when working with integers?

7 messages · Page 1 of 1 (latest)

summer scarab
#

I've read that when multiplying integers it is best not to use the pow() function of math.h, since it accept and returns double value.
So what is a typical way of doing it?
I've also read about replacing pow() by an array lookup into a precomputed table of powers of 10, but i'm not sure what is meant by that.

nocturne schoonerBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

dapper dawn
#

Writing an integer exponentiation routine yourself. Algorithms are available out there.

#

"Precomputed table" just means you already have a table of all the results somewhere and just get to the corresponding entry when it's needed, say a multiplication table:

8.0 = 0
8.1 = 8
8.2 = 16
8.3 = 24
8.4 = 32
8.5 = 40
8.6 = 48
8.7 = 56
8.8 = 64
8.9 = 72
8.10 = 80

summer scarab
#

i'll look into it, thanks.

nocturne schoonerBOT
#

@summer scarab Has your question been resolved? If so, type !solved :)

summer scarab
#

!solved