Re: calculate value of 73!

From: Richard Heathfield (dontmail_at_address.co.uk.invalid)
Date: 02/08/04


Date: Sun, 8 Feb 2004 09:07:09 +0000 (UTC)

Mark Shelor wrote:

> Saurabh Saxena wrote:
>
>> can we calculate the 73! value in c or c++ without loss of significant
>> digits.
>
>
> Saurabh,
>
> As you perhaps already know, the value of 73! is
>
> 44701154615126843408912571381250511100768007002829050158190800923704\
> 22104067183317016903680000000000000000

Right. (Well, it looks right at first glance; I haven't checked every
digit.)

> This is a value whose precision (number of digits in its representation)
> exceeds that of all integral and floating types defined by (drum roll
> please) ... THE STANDARD.

Not so. The Standard imposes no maxima on precision levels - only minima.

> In other words, to compute 73! using Standard
> C, you'll need to develop a multiple-precision data structure and
> associated computation procedure. There are myriad ways to do this;
> Knuth Vol. 2 is a useful reference.

Excellent advice.

>
> However, since the term "multiple-precision" is probably nowhere
> mentioned in (drum roll please) THE STANDARD, you may want to be careful
> about mentioning it any further, lest one of the newsgroup nannies, in
> their never-ending quest for absolute purity, raps you on the knuckles
> with a hard ruler.

This is unlikely. It is, however, true that the writing of "multiple
precision" libraries is less to do with C and more to do with programming.
Having said that, if someone were to run into a C problem whilst
programming a multiple precision library, I see no reason why they
shouldn't seek help for their C question here.

-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton


Relevant Pages

  • Re: Fun With Numbers
    ... If you want to do exact addition, subtraction, multiplication, ... has reports that generate nine digits worth in some reports. ... referred to the ECMAScript standard (ECMA-262 5.1 Edition of June ... that it is good for 15.95 digits of precision. ...
    (comp.lang.javascript)
  • Re: Random floats function
    ... >> 1) The C standard makes no guarantee whatsoever about the ... long double often has more precision ... Using 40 decimal digits will cover anything with a mantissa up to 128 ...
    (comp.lang.c)
  • Re: SELECTED_REAL_KIND clarification plse
    ... sign, would satisfy four digits. ... There is work toward a decimal based floating point standard ... available precision and range as binary. ... It would make sense to specify ...
    (comp.lang.fortran)
  • Re: Floating point precision
    ... I read somewhere that the C99 standard ... guarantees six digits of precision with the float ...
    (comp.lang.c)
  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... precision numbers in oracle, you've got 38 decimal digits to play ... and with minimal coaxing perl will handle them as ... digits from a 32 bit floating point number - I'll go out on a limb ... and hazard that one can expect 12 or so digits from a 64 bit floating ...
    (perl.dbi.users)