Re: how to compute

Paul Dietz <[email protected]> Tue, 16 May 2006 13:59:18 -0500
Newsgroups gmane.lisp.allegro
Organization GSG Software Design Automation
Message-ID <[email protected]>
Yaling Zheng wrote:
> Does any one know how to calculate the exact value of the ratio (such
> as 6042715942219502152353483497843569525253244555916134 over 200)?
> 
> CL-USER(68): (float (/ 6042715942219502152353483497843569525253244555916134 200))
> #.EXCL::*INFINITY-SINGLE*
> 
> Thanks,
> Yaling
> 
> 

If you want a non-infinite float result, you need to specify a type that
can contain the result.  Single float was too small here.

(float (/ 6042715942219502152353483497843569525253244555916134 200) 1.0d0)

==> 3.0213579711097513e+49

That's not 'exact' as you said you wanted, though.  Just calling /
gives the exact rational:

(/ 6042715942219502152353483497843569525253244555916134 200)

==> 3021357971109751076176741748921784762626622277958067/100

	Paul