Re: factorial and exponent



Army1987 wrote, On 17/06/07 09:48:
"Richard Heathfield" <rjh@xxxxxxxxxxxxxxx> ha scritto nel messaggio news:Gv6dnQ2-P8SDeunbnZ2dnUVZ8t_inZ2d@xxxxxxxxx
BiGYaN said:

On Jun 16, 5:02 pm, Thomas <mynameisthomasander...@xxxxxxxxx> wrote:
I want to calculate the value of 126 raise to the power 126 in turbo
C.
I've checked it with unsigned long int but it doesn't help.
So how could one calculate the value of such big numbers?
What's the technique?
Use GMP library found in http://gmplib.org/
It will enable you to do "Arithmetic without Limitations" !!
Nonsense.

Consider an integer greater than or equal to 2. Call it A. Consider
another integer greater than or equal to 2. Call it B.

Raise A to the power B, storing the result in A. Now raise B to the
power A, storing the result in B. If you repeat this often enough, you
*will* hit a limit, no matter what numerical library you use.

But it is a limit of your computer, not of the library itself.

If it uses space allocated with malloc/realloc, then the library (rather than the computer) has a limit because even with an infinite computer size_t and pointers are of defined finite size, so you can only have a block of known finite size and you can only chain a finite number of such blocks together with pointers.

Of course, this applies to all libraries written in C.

It is also very important for people learning to be programmers (or who already are programmers) to understand that in the real world resources are always limited, so there is no such thing as "without limitations".
--
Flash Gordon
.



Relevant Pages

  • Re: Writing bulletproof code
    ... Good software design requires that you put error ... > the 'C' language and the libraries. ... It doesn't actually solve the problem that programmers are ... very few know when the cost will be negligible ...
    (comp.programming)
  • Re: <ctype.h> toLower()
    ... I konow several real world programmers, ... >> And portability is in most cases a very low priority as in most cases ... > the past 10 years I only wrote some specific platform specific software. ... > libraries did their job well). ...
    (alt.comp.lang.learn.c-cpp)
  • Re: How does Require deal with multiple files of the same name in different directories
    ... This meant that programmers developed their own ... libraries had almost the same functionality they have been merged into ... specific implementation details; hopefully that will be improved as ... to add pre-emptive multi-tasking, to have a separate code ...
    (comp.lang.forth)
  • Re: Writing bulletproof code
    ... >> Efficiency is part of good coding. ... the 'C' language and the libraries. ... >> where most programmers seem to go wrong, ... >> triple checking is more important than efficiency. ...
    (comp.programming)
  • Re: google "top coder" contest = stacked against C++ coders
    ... >Let me add a little more on the value of portability even to novice ... >programmers. ... Comeau C/C++ with Dinkumware's Libraries... ...
    (comp.lang.cpp)