Re: Calculating exponents without library functions

From: rossum (rossum48_at_coldmail.com)
Date: 04/21/04


Date: Tue, 20 Apr 2004 23:31:35 +0100

On Mon, 19 Apr 2004 10:45:04 +0100, Richard Herring <junk@[127.0.0.1]>
wrote:

>In message <seg080homgoqcjk45pt4vv67qmja7o1aai@4ax.com>, rossum
><rossum48@coldmail.com> writes
>>On Fri, 16 Apr 2004 09:34:20 +1200, Bruce Clement
>><kiore-at-kiore-dot-com@server.example.com> wrote:
>>
>>>Richard Herring wrote:
>>>> In message <c5ldnc$ctu$1@server.kiore.com>, Bruce Clement
>>>> <kiore-at-kiore-dot-com@server.example.com> writes
>>>>
>>>>> Matt wrote:
>>>>>
>>>>>> David wrote:
>>>>>>
>>>>>>> How can you write a program in C++ by using loop to control the
>>>>>>> calculation
>>>>>>> without the use of library function pwr .For example 3 to the power
>>>>>>> of 4 (ie
>>>>>>> 3x3x3x3). Any help will be appreciated
>>>>>>
>>>>>> Try posting to comp.lang.c++.homework.
>>>>>>
>>>>>
>>>>> Try something like this. It uses a redundant loop and calculates
>>>>> X to the power of Y in approximately Y! steps.
>>>>>
>>>>>
>>>[...]
>>>>
>>>> Couldn't you use a recursive function here instead of operator* ?
>>>>
>>>[...]
>>>
>>>LOL, You're evil. I like that in a person. :)
>>
>>
>>Real programmers do it with the Peano Axioms
>
>[snip program]
>
>Indeed. Now do it for _double_ arguments ;-)

Only if you can give me an equivalent of the Peano Axioms (which only
cover integers) for real numbers. The problem is how to
mathematically define "successor" in the real number domain.

rossum

--
The Ultimate Truth is that there is no Ultimate Truth


Relevant Pages