KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was always wondering how I can make a function which calculates the power (e.g. 2 3 ) myself. In most languages these are included in the standard library, mostly as pow(double x, double y) , but how can I write it myself? I was thinking about for loops , but it think my brain got in a loop (when I wanted to do a power with a non-integer exponent, like 5 4.5 or negatives 2 -21 ) and I went crazy ;) So, how can I write a function which calculates the power of a real number? Thanks Oh, maybe important to note: I cannot use functions which use powers (e.g. exp ), which would make this ultimately useless.
Tags (comma-separated)
Save Edits
Cancel