473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Decimal places and huge fractions.

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?

Jul 19 '05 #1
5 3268
Eoin Mcloughlin <an*************@phreaker.net> wrote in message
news:40**************@phreaker.net...
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....


Jul 19 '05 #2
In article <40**************@phreaker.net>, Eoin Mcloughlin
<an*************@phreaker.net> 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.
Jul 19 '05 #3
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
Jul 19 '05 #4
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
Jul 19 '05 #5
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...

Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
2
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I...
11
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a...
0
by: pomeroymiles | last post by:
I have a pivotchart which I cause to take a huge list of people's test percentiles and calculate the average for each year. I then display the average above each bar. The problem is that there are...
9
by: arun.hallan | last post by:
I need to derive fractions from decimals as so: 0.3333 = 1/3 0.6666 = 2/3 The decimal could also be 0.33, or 0.3333333 but the point is that it that the fraction needs to be extracted. ...
28
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
6
by: Terry Reedy | last post by:
Gerhard Häring wrote: The new fractions module acts differently, which is to say, as most would want. True Traceback (most recent call last): File "<pyshell#20>", line 1, in <module> F(1.0)...
4
by: Astley Le Jasper | last post by:
I've been getting errors recently when using pysqlite. I've declared the table columns as real numbers to 2 decimal places (I'm dealing with money), but when doing division on two numbers that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.