473,406 Members | 2,467 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,406 software developers and data experts.

about presicion

Ali
I was wondering if it was posible to get very good presicion. I mean
like to the to the 100 th or more decimal place. if so how?
Jul 18 '05 #1
7 1656
al**********@hotmail.com (Ali) wrote in message news:<8f**************************@posting.google. com>...
I was wondering if it was posible to get very good presicion. I mean
like to the to the 100 th or more decimal place. if so how?


You can have infinite, or at least arbitrary precision, if you do all
calculations on rational numbers. Doing this will probably be very
slow compared to calculations on floats, ints, or longs, however,
especially if implemented in pure Python.

A compromise would be to use a fixed-point representation. If you
needed 100 decimal digits after the decimal point, and say, 10 before
the decimal point, you could accomplish that (and actually a teeny bit
more) using a 368-bit fixed-point representation. This could possibly
be fast in Python, depending on the implementation.

It all depends what your requirements are.
Jul 18 '05 #2
Mensanator <me********@aol.compost> wrote:
Subject: Re: about presicion
From: Peter Hansen pe***@engcorp.com
Date: 8/28/04 10:31 PM Central Daylight Time
Message-id: <JN********************@powergate.ca>

Ali wrote:
The decimal module comes with python 2.4? I have 2.3, :(, what do I do?
The obvious answer is, well, obvious. The real question is
what's stopping you from upgrading?


I just tried it and found out it's not compatible with gmpy.


By "it" do you mean Decimal, or Python 2.4 alpha 2? I think gmpy should
build happily with the latter, and interoperate sensibly with Decimal
anyway -- as gmpy's author I'd be quite happy to fix gmpy if it's broken
in either respect.
Of course, I wouldn't need gmpy to get big floats, but I
would then lose all the math functions like linear congruence
and modular inverse that my programs depend on.

So I, for one, will have to wait for the rest of the world to
catch up to 2.4.


2.4 is not currently recommended for production work (that's why it's in
Alpha -- very good for an alpha, but it's still not a final release).
But such support modules as gmpy need to get moving to support 2.4 in
order to be ready for it well before final release...
Alex
Jul 18 '05 #3
Ali <al**********@hotmail.com> wrote:
So the decimal module is in 2.4 but not 2.3? Also I am not geting the
2.4 version because it seems that it is still in alpha.


You _SHOULD_ get the 2.4 alpha, and try it out -- that's why alphas get
released, after all! How's the final release going to be perfect unless
people DO get and try the alphas?!

But you shouldn't yet use 2.4 for production work (stuff you ship to
customers, etc).

The Decimal module is in the standard library in 2.4, but Decimal itself
can support 2.3 just fine -- just download and install it.
Alex
Jul 18 '05 #4
Ali
al*****@yahoo.com (Alex Martelli) wrote in message news:<1gjc18t.1hj0z071lwprfjN%al*****@yahoo.com>.. .
Ali <al**********@hotmail.com> wrote:
So the decimal module is in 2.4 but not 2.3? Also I am not geting the
2.4 version because it seems that it is still in alpha.


You _SHOULD_ get the 2.4 alpha, and try it out -- that's why alphas get
released, after all! How's the final release going to be perfect unless
people DO get and try the alphas?!

But you shouldn't yet use 2.4 for production work (stuff you ship to
customers, etc).

The Decimal module is in the standard library in 2.4, but Decimal itself
can support 2.3 just fine -- just download and install it.
Alex


ok but where can i download deciaml? waht about gmpy? which is better?
Jul 18 '05 #5
Ali <al**********@hotmail.com> wrote:
...
ok but where can i download deciaml? waht about gmpy? which is better?


Decimal (for 2.3): file decimal.py from:
http://cvs.sourceforge.net/viewcvs.p.../dist/src/Lib/

With 2.4 it will come as part of the standard library.

gmpy: http://gmpy.sourceforge.net.\/
"Which is better" for _WHAT_ task? If you need decimal arithmetic,
obviously Decimal, since gmpy doesn't support it -- gmpy uses binary
throughout. If you need huge-precision binary floats,
unbounded-precision rational numbers, very fast operations such as
factorials and binomial coefficients on unbounded-precision integers,
then obviously gmpy, since Decimal doesn't support any of these --
Decimal does its job, which is decimal arithmetic, period.

I cannot imagine offhand any task for which I would be in doubt between
using Decimal and using gmpy -- sure, they both deal with numbers, but
there's basically no overlap between their functionality.
Alex
Jul 18 '05 #6
me********@aol.com <me********@aol.com> wrote:
...
I just tried it and found out it's not compatible with gmpy.


By "it" do you mean Decimal, or Python 2.4 alpha 2?


By "it", I meant gmpy 1.0 and Python 2.4. Trying to import the
module says it can't use the Python23.dll.


_Any_ binary extension Python module compiled for Python 2.3 cannot even
load (on Windows) with Python 2.4 -- this has always been true on
Windows between any two releases of Python and will presumably continue
to be so for the foreseeable future.

This doesn't mean that Python 2.4 "is not compatible with gmpy" or
viceversa: it just means you obviously need to use a gmpy binary (pyd
file) compiled for the version of Python you're using. Just as it would
be the case for any other binary extension module whatsoever.

Unfortunately, compiling any binary extension module on Windows for
Python 2.4 requires Microsoft's very latest C++ compiler -- I do not own
a copy, nor do I have any PC normally running Windows XP, which is
required to run that compiler. Until Pyhon 2.3, I made do with a
Windows 98 session running under win4lin on one of my Linux machines,
and good old Microsoft Visual C++ 6 -- but such limited resources are
not sufficient any longer to compile Python binary extension modules for
Python 2.4. Since in terms of income-making (as well as leisure;-) I
work by now only on MacOSX, Linux, and OpenBSD machines, I am not going
to buy a PC loaded with Microsoft software just to be able to donate
precompiled Python binary extension modules to Windows users.

I think gmpy should
build happily with the latter,


I'm using the pre-built Windows binary distribution. I wouldn't
know how to re-build it. I assume that when Python 2.4 is final,
I newer compatible version of gmpy will become available.


Not by magic -- I hope somebody out there owns all the needed Microsoft
software and is interested in compiling gmpy for Windows under Python
2.4 and making it available, but it won't be me.

and interoperate sensibly with Decimal
anyway -- as gmpy's author I'd be quite happy to fix gmpy if it's

broken
in either respect.


Were you aware that there is apparently a memory leak in the
gmpy.divm() function? Calling it several million time caused my
computer to run out of virtual memeory. Luckily, I was able to
work around it using the gmpy.invert() which didn't consume any
memory regardless of how many times it was called.


No, I was not aware of that -- I'll look into it, thanks.
Alex
Jul 18 '05 #7
Anthony Baxter <an***********@gmail.com> wrote:
Another approach is to find someone with the appropriate toolchain
(VS7.1) and get them to do:

% python setup.py install
% python setup.py bdist_wininst

and then make the windows installer for the gmpy module available.
Sounds good -- are you volunteering?-)

My understanding is that building 2.4 modules with either mingw or the
freely available MS compiler is still a non-trivial exercise - but
there's enough people interested in this that I suspect it will be
resolved soon enough.


Thanks for the info! And let's indeed hope things get better... if
mingw sufficed I could use it on my old trusty Win98-on-Win4Lin-
on-Linux setup, for example (gmpy does need speed, so maybe it's best to
build it with the best optimizing compiler available, but other modules
may not be quite as speed-critical as that).
Alex
Jul 18 '05 #8

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

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
3
by: Andrus | last post by:
How to implement function string Str( float number, ushort width, ushort presicion) should return string whose size if width characters, left padded by spaces and having presicion characters...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
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...
0
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...

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.