473,804 Members | 3,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3286
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
metorologica l 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
4542
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
6157
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. "Decimal Number" sometimes serves to distinguish Base 10 numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal Number" serves to differentiate a number from an integer. For the rest of this post I shall only use either...
2
3605
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 can't figure out why the design is so that the DataRow "alters" the value entered. In my application a decimal column in a row of a specific table has a fix number of decimal places according to certain premises. The
11
2260
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 Single with value 4.475 was converted to a Decimal with value 4.4749999999999996D. So after inserting and selecting it from the database I got another value than the original!
0
1874
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 too many numbers after the decimal place for each figure. I went into the properties and changed the number format to "fixed" but it doesn't give me the option to change the number of decimal places that are used (it does every where else in MS...
9
2505
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. The reason for this is a UI restriction, where users can only enter a percentage. But in the case where a third needs to be expressed, a
28
5939
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places? ----------------------------------------------------------------------- When formatting money for example, to format 6.57634 to 6.58, 6.5 to 6.50, and 6 to 6.00? Rounding of x.xx5 is uncertain, as such numbers are not represented exactly. See section 4.7 for Rounding issues.
6
3717
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) File "C:\Program Files\Python30\lib\fractions.py", line 97, in __new__
4
4269
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 happen to have no decimal fractions, the results through pysqlite are coming through as integers. The funny thing is that when looking at the database using SQLite Manager or SQLite Pro the results there are displayed correctly. As a temporary fix...
0
9572
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.