Re: Rather large number

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Tue, 24 Nov 1998, Rolf Schroeder wrote:
> Molasses wrote:
> > Could anyone please help me in a large calculation?
> > Let me specify 'large':
> >
> > (480000^16777216) / 756864000
> >
> > It's the number of years it would take to watch a screen 800x600 24bit
> > color go through every possible combination at 24 frames per second.
>
> You will get with Eu only the log. Here the code:
> --
> --  d = (480000^16777216) / 756864000
> --
> constant cE     = 2.718281828459045
> ----------------------------------------------------------------
> function exp( object x)             -- Exponential function
>     return power(cE,x)
> end function
> ----------------------------------------------------------------
>
>     atom  a,  b,  c
>     atom ln, ld
>
>     a = 480000
>     b = 16777216
>     c = 756864000
>
>     ln = b * log(a) - log(c)
>     ld = ln/log(10)
>     printf(1,"Nat. log: %25.15e\n", ln)
>     printf(1,"Dec. log: %25.15e\n", ld)

The maths looks good. This, according to a non-Euphoria package I'm using
(Maple V3) yields (for the decimal log):

95315402.49 (approx)

So that means the answer is roughly 3.1e+95315402 years.
By comparison, the universe is roughly 1.5e+10 years old. :)

Function time!

function split_antilog10(atom log10_x)
    -- Expects log10_x to be the log (base 10) of x (Unsurprisingly)
    -- returns {mantissa, exponent}
    atom mantissa
    integer exponent

    exponent = floor(log_x)
    mantissa = power(10,(log_x - exponent))

    return {mantissa, exponent}
end function

Use this in the above program with:

printf(1, "%1.15ge+%d", split_antilog10(ld))

--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
URL......: http://www.bigfoot.com/~cyrek/
Ykk rnyllaqur rgiokc cea nyemdok ymc giququezka caysgr -- B.Q.Vgesa

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu