Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Calculate A to the power P.
- Float: RaiseToPower(Float: A, Integer: P)
- <Use the first fact to quickly calculate A, A2, A4, A8, and so on
- until you get to a value AN where (N + 1 > P) >
- <Use those powers of A and the second fact to calculate AP>
- Return AP
- End RaiseToPower
- That's fewer multiplications than simply multiplying 7 × 7 × 7 × 7 × 7 × 7, but it's a small difference in this example.
- Excerpt From: Stephens, Rod. “Essential Algorithms.” iBooks.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement