Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. // Calculate A to the power P.
  2. Float: RaiseToPower(Float: A, Integer: P)
  3. <Use the first fact to quickly calculate A, A2, A4, A8, and so on
  4. until you get to a value AN where (N + 1 > P) >
  5.  
  6. <Use those powers of A and the second fact to calculate AP>
  7. Return AP
  8. End RaiseToPower
  9.  
  10. That's fewer multiplications than simply multiplying 7 × 7 × 7 × 7 × 7 × 7, but it's a small difference in this example.
  11.  
  12. Excerpt From: Stephens, Rod. “Essential Algorithms.” iBooks.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement