Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Decimal places and huge fractions.

Reply
Thread Tools

Decimal places and huge fractions.

 
 
Eoin Mcloughlin
Guest
Posts: n/a
 
      02-11-2004
I have a perl script for calculating sequences that use numbers like
1/5908979186 however, I need to get more accuracy than the usual 15
decimal places, is this a limitation of 32-bit machines or is it
possible to use more decimal places?
Has something already been written to do this? If not, what would one
have to do enable it?

 
Reply With Quote
 
 
 
 
Chris Crandell
Guest
Posts: n/a
 
      02-12-2004
Eoin Mcloughlin <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a perl script for calculating sequences that use numbers like
> 1/5908979186 however, I need to get more accuracy than the usual 15
> decimal places, is this a limitation of 32-bit machines or is it
> possible to use more decimal places?
> Has something already been written to do this? If not, what would one
> have to do enable it?
>


If you need more precision, then 32 or 64 or .... becomes an issue.
One possible solution is to do the arithmetic in string form which bypasses
the machine limitation. It requires special functions for doing the string
arithmetic but
I have to guess it's been done ... somewhere. (ie once upon a time for a
class we
did at least the easier add, subtract, multiply ....maybe divide)
There is a time cost, of course.

Regards....




 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      02-12-2004
In article <(E-Mail Removed)>, Eoin Mcloughlin
<(E-Mail Removed)> wrote:

> I have a perl script for calculating sequences that use numbers like
> 1/5908979186 however, I need to get more accuracy than the usual 15
> decimal places, is this a limitation of 32-bit machines or is it
> possible to use more decimal places?
> Has something already been written to do this? If not, what would one
> have to do enable it?
>


Check out Math::BigInt (I have not used it). Try

perldoc Math::BigInt

for info.

FYI: This newsgroup is defunct. Try comp.lang.perl.misc in the future.
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      02-12-2004
Eoin Mcloughlin wrote:
> I have a perl script for calculating sequences that use numbers like
> 1/5908979186 however, I need to get more accuracy than the usual 15
> decimal places,


More accuracy? Are you doing some astronomic calculations or iterative
metorological forcasts or nuclear physics or something like that?
Ususally 10 valid digits (as in your example) are more than any measuring
equipment can possibly provide.

However, if you really have a need for higher accuracy then you may want to
invest some time in learning about computer numerics and how those work.
There is much more to it then just using a module with a higher number of
digits and if you are not aware of the potential pitfalls then you are
likely to be bitten sooner or later.

jue


 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      02-12-2004
Eoin Mcloughlin wrote:

> I have a perl script for calculating sequences that use numbers like
> 1/5908979186 ...


http://search.cpan.org/search?query=...mbers&mode=all
Math::BigInt and Math::BigRat.
-Joe
 
Reply With Quote
 
Eoin Mcloughlin
Guest
Posts: n/a
 
      02-13-2004
A bunch people wrote:


>More accuracy? Are you doing some astronomic calculations or iterative
>metorological forcasts or nuclear physics or something like that?

Well, not quite but there are sequences with unusual numbers in them...

>Math::BigInt and Math::BigRat

Math::BigFloat worked just fine...

Thanks people... Great help. Everything is fine to 300-odd decimal
places, which will do for now...

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Decimal Places Harry ASP .Net 3 06-03-2004 07:19 PM
Re: beginner: prob with decimal places Curt_C [MVP] ASP .Net 2 05-18-2004 08:38 PM
Re: beginner: prob with decimal places Curt_C [MVP] ASP .Net 1 05-18-2004 07:27 PM
Classic ASP Table to DataGrid...formatting color and decimal places Next ASP .Net Datagrid Control 1 08-27-2003 11:10 PM
Decimal Places Bharat Bhushan Java 2 08-08-2003 05:28 PM



Advertisments