Hi!
I am using rational numbers from the gmpy module and I find that creating
one in Python using
mpq(3,4)
is rather clumsy. Clearly, minimal representation of this rational number
is
3/4
but in Python this expression has different meaning.
Hi,
I am writing an interface module
On 2007-02-23 16:35, Martin Manns wrote:
Hi,
I am starting to use rationals and since I found no batteries included,
I tried out the mxNumber package.
However, I get strange warnings on comparison operations
(which however seem to yield correct results):
---
$ python
Python 2.4.3
[EMAIL PROTECTED] wrote:
On Feb 25, 3:09 pm, Fernando Perez [EMAIL PROTECTED] wrote:
Alex, have you had a look at SAGE?
http://modular.math.washington.edu/sage/
it uses GMP extensively, so they've had to patch it to work around these
issues. You can look at the SAGE release (they package
On Feb 25, 3:09 pm, Fernando Perez [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
gmpy itself is or should be pretty trivial to build on any platform
(and I'll always happily accept any fixes that make it better on any
specific platform, since it's easy to make them conditional so
On Feb 24, 12:25 am, Toby A Inkster [EMAIL PROTECTED]
wrote:
aleaxit wrote:
If anybody who has easy access to Microsoft's MSVC++.NET (and is willing
to try building GMP 4.2 with/for it), or a PPC Mac with XCode installed
(possibly with MacOSX 10.3...)
I'm writing this message on a MacOS
[EMAIL PROTECTED] wrote:
gmpy itself is or should be pretty trivial to build on any platform
(and I'll always happily accept any fixes that make it better on any
specific platform, since it's easy to make them conditional so they'll
apply to that platform only), but the underlying GMP is
En Sat, 24 Feb 2007 01:42:00 -0300, Martin Manns [EMAIL PROTECTED] escribió:
On Fri, 23 Feb 2007 20:20:12 -0300
Gabriel Genellina [EMAIL PROTECTED] wrote:
mx.Number.Rational is horribly broken. They break this rule:
a==b = hash(a)==hash(b)
so they can'b be used as dictionary keys, by
aleaxit wrote:
If anybody who has easy access to Microsoft's MSVC++.NET (and is willing
to try building GMP 4.2 with/for it), or a PPC Mac with XCode installed
(possibly with MacOSX 10.3...)
I'm writing this message on a MacOS 10.3.9 box with Xcode 1.5 (gcc 3.3)
installed. If you tell me how,
Hi,
I am starting to use rationals and since I found no batteries included,
I tried out the mxNumber package.
However, I get strange warnings on comparison operations
(which however seem to yield correct results):
---
$ python
Python 2.4.3 (#1, Jan 15 2007, 15:46:19)
[GCC 4.1.1 (Gentoo
Martin Manns wrote:
Hi,
I am starting to use rationals and since I found no batteries included,
I tried out the mxNumber package.
However, I get strange warnings on comparison operations
(which however seem to yield correct results):
---
$ python
Python 2.4.3 (#1, Jan 15 2007,
On Fri, 23 Feb 2007 09:52:06 -0600
Larry Bates [EMAIL PROTECTED] wrote:
I quick search of Google turned up:
http://books.google.com/books?id=1Shx_VXS6ioCpg=PA625lpg=PA625dq=python+rational+number+librarysource=webots=BA8_4EXdQ4sig=aDEnYA99ssKe7PSweVNyi8cS2eg
On Fri, 23 Feb 2007 11:39:11 -0500
Martin Manns [EMAIL PROTECTED] wrote:
+ boost indeed is a quite nice C++ library. However, I fear that I
would end up writing the python wrappers for operators (+ - * / min
max cmp etc.) myself. I would like to avoid this since these operators
should work
Martin Manns:
+ gmpy is looking pretty unmaintained (dead) to me (newest update of
cvs 10 months ago).
I have used it on Py2.5, so it seems to work anyway, and it's fast
enough for my purposes. And probably soon some alex-shaped life will
show up elsewhere.
Bye,
bearophile
--
On Feb 23, 10:39 am, Martin Manns [EMAIL PROTECTED] wrote:
On Fri, 23 Feb 2007 09:52:06 -0600
Larry Bates [EMAIL PROTECTED] wrote:
I quick search of Google turned up:
http://books.google.com/books?id=1Shx_VXS6ioCpg=PA625lpg=PA625dq=p...
http://calcrpnpy.sourceforge.net/clnum.html
In [EMAIL PROTECTED], Martin Manns wrote:
+ gmpy is looking pretty unmaintained (dead) to me (newest update of
cvs 10 months ago).
What CSV activities do you expect? This package seems to be pretty
stable. As long as there is no bug or incompatible changes in the
underlying library I would
On Feb 23, 10:34 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
On Feb 23, 10:39 am, Martin Manns [EMAIL PROTECTED] wrote:
On Fri, 23 Feb 2007 09:52:06 -0600
Larry Bates [EMAIL PROTECTED] wrote:
I quick search of Google turned up:
On 23 Feb 2007 12:00:10 -0800
[EMAIL PROTECTED] wrote:
I worked with Alex Martelli (gmpy's maintainer) to fix a bug found by
mensanator. With Alex's permission, I released it as gmpy 1.04a. Alex
has not updated cvs with the fix.
gmpy 1.04a compiles cleanly with the latest releases of
On Feb 23, 2:00 pm, [EMAIL PROTECTED] wrote:
On Feb 23, 10:34 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
On Feb 23, 10:39 am, Martin Manns [EMAIL PROTECTED] wrote:
On Fri, 23 Feb 2007 09:52:06 -0600
Larry Bates [EMAIL PROTECTED] wrote:
I quick search of Google turned up:
Am I hallucinating? Didn't I see at least some version
of gmpy for Python 2.5 on SourceForge awhile back?
I distinctly remember thinking that I don't have to
direct people to your site, but SourceForge is not
showing anything beyond vesion 1.01 for Python 2.4.
Alex released versions 1.02
En Fri, 23 Feb 2007 12:35:19 -0300, Martin Manns [EMAIL PROTECTED] escribió:
I am starting to use rationals and since I found no batteries included,
I tried out the mxNumber package.
However, I get strange warnings on comparison operations
(which however seem to yield correct results):
On Feb 23, 12:00 pm, [EMAIL PROTECTED] wrote:
...
+ gmpy is looking pretty unmaintained (dead) to me (newest update of
cvs 10 months ago).
I worked withAlex Martelli(gmpy's maintainer) to fix a bug found by
mensanator. With Alex's permission, I released it as gmpy 1.04a. Alex
has not
On Feb 23, 2:52 pm, [EMAIL PROTECTED] wrote:
Am I hallucinating? Didn't I see at least some version
of gmpy for Python 2.5 on SourceForge awhile back?
I distinctly remember thinking that I don't have to
direct people to your site, but SourceForge is not
showing anything beyond vesion
On Feb 23, 3:27 pm, [EMAIL PROTECTED] wrote:
On Feb 23, 12:00 pm, [EMAIL PROTECTED] wrote:
...
+ gmpy is looking pretty unmaintained (dead) to me (newest update of
cvs 10 months ago).
I worked withAlex Martelli(gmpy's maintainer) to fix a bug found by
mensanator. With Alex's
On Feb 23, 3:44 pm, [EMAIL PROTECTED] wrote:
...
I can keep building gmpy for Windows. I actually use MINGW since
getting GMP compiled under MSVC is challanging. I should be able to
build new binaries for Windows this weekend. And I would be happy to
point everyone to a real release.
On Fri, 23 Feb 2007 20:20:12 -0300
Gabriel Genellina [EMAIL PROTECTED] wrote:
En Fri, 23 Feb 2007 12:35:19 -0300, Martin Manns [EMAIL PROTECTED]
escribió:
I am starting to use rationals and since I found no batteries
included, I tried out the mxNumber package.
However, I get strange
Looks pretty much the same as mx.Number
Does this warning come up from gmp? Do I have to compile it with
different flags?
Or do both wrappers use the same code?
I would like to encourage the python community (i.e. the guys
maintaining the python docs) to point out a recommended rational
On 23 Feb 2007 22:19:30 -0800
[EMAIL PROTECTED] wrote:
Looks pretty much the same as mx.Number
Does this warning come up from gmp? Do I have to compile it with
different flags?
Or do both wrappers use the same code?
I would like to encourage the python community (i.e. the guys
In article [EMAIL PROTECTED],
Hendrik van Rooyen [EMAIL PROTECTED] writes:
|
| Financial calculations need decimal FIXED-point, with a precisely
| specified precision. It is claimed that decimal FLOATING-point
| helps with providing that, but that claim is extremely dubious.
| I can explain
In article [EMAIL PROTECTED],
Hendrik van Rooyen [EMAIL PROTECTED] writes:
|
| Ok I will throw in a skewed ball at this point - use integer arithmetic,
| and work in tenths of cents or pennies or whatever, and don't be too
| lazy to do your own print formatting...
If anyone is interested in
In article [EMAIL PROTECTED],
Steven D'Aprano [EMAIL PROTECTED] writes:
|
| Some of the algebraic languages. (2/3)^(1/5) is held as such and
| manipulated appropriately.
|
| Yes, I know that's cheating :-)
|
| I see your smiley, and I still don't understand. Why on earth would you
| call
In article [EMAIL PROTECTED],
Simon Brunning [EMAIL PROTECTED] writes:
|
| Financial calculations need decimal FIXED-point, with a precisely
| specified precision. It is claimed that decimal FLOATING-point
| helps with providing that, but that claim is extremely dubious.
| I can explain the
From: Nick Maclaren [EMAIL PROTECTED] wrote:
Financial calculations need decimal FIXED-point, with a precisely
specified precision. It is claimed that decimal FLOATING-point
helps with providing that, but that claim is extremely dubious.
I can explain the problem in as much detail as you
On Thu, 2007-01-11 at 23:47 +, Nick Maclaren wrote:
In article [EMAIL PROTECTED],
Facundo Batista [EMAIL PROTECTED] writes:
| Noud Aldenhoven wrote:
|
| When I was programming in a mathematical project I began to wonder if
python
| supports rational numbers[1]. In a language like
began to wonder if
python
| | supports rational numbers[1]. In a language like magma[2] it's not
such a
| | problem. Does python supports something simular?
| |
| | Python does not have rational numbers.
| |
| | There's a (rejected) PEP about this, PEP-239:
| |
| | http
rational numbers.
| |
| | There's a (rejected) PEP about this, PEP-239:
| |
| | http://www.python.org/dev/peps/pep-0239/
| |
| | Maybe you also want to read the section Why not rational? of
| | PEP-327...
| |
| | http://www.python.org/dev/peps/pep-0327/#why-not-rational
In article [EMAIL PROTECTED],
Carsten Haese [EMAIL PROTECTED] writes:
|
| Ah, so now you're putting words in the BDFL's mouth. ;)
|
| The pronouncement does say The needs outlined in the rationale section
| have been addressed to some extent by the acceptance of PEP 327 for
| decimal
Noud Aldenhoven wrote:
There are a (small) couple of other issues where rational numbers could be
handy. That's because rational numbers are exact, irrational numbers (in
python) aren't. But these issues are probably too mathematical to be used in
For the sake of me being less ignorant, could
In article [EMAIL PROTECTED],
Facundo Batista [EMAIL PROTECTED] writes:
| Noud Aldenhoven wrote:
|
| There are a (small) couple of other issues where rational numbers could be
| handy. That's because rational numbers are exact, irrational numbers (in
| python) aren't. But these issues
On 1/12/07, Facundo Batista [EMAIL PROTECTED] wrote:
Noud Aldenhoven wrote:
There are a (small) couple of other issues where rational numbers could
be
handy. That's because rational numbers are exact, irrational numbers (in
python) aren't. But these issues are probably too mathematical
On 12 Jan 2007 15:55:39 GMT, Nick Maclaren [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Carsten Haese [EMAIL PROTECTED] writes:
| but there are more use
| cases for Decimal than for Rational.
That is dubious, but let's not start that one again.
Decimals are good for holding
In article [EMAIL PROTECTED],
Simon Brunning [EMAIL PROTECTED] writes:
|
| | but there are more use
| | cases for Decimal than for Rational.
|
| That is dubious, but let's not start that one again.
|
| Decimals are good for holding financial values. There's a whole lot of
| software out
Simon Brunning schrieb:
On 12 Jan 2007 15:55:39 GMT, Nick Maclaren [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Carsten Haese [EMAIL PROTECTED] writes:
| but there are more use
| cases for Decimal than for Rational.
That is dubious, but let's not start that one again.
Decimals
On 12 Jan 2007 19:41:52 GMT, Nick Maclaren [EMAIL PROTECTED] wrote:
Sigh. I was hoping not to have that myth perpetrated again.
Financial calculations need decimal FIXED-point, with a precisely
specified precision. It is claimed that decimal FLOATING-point
helps with providing that, but
On 1/12/07, Thomas Ploch [EMAIL PROTECTED] wrote:
Do not forget:
- Time
- Personal Data (like birthdays, age)
The datetime module has perfectly good classes for holding date and
time values, and age sounds like an integer to me.
--
Cheers,
Simon B
[EMAIL PROTECTED]
--
On Fri, 12 Jan 2007 20:07:04 +, Simon Brunning wrote:
On 1/12/07, Thomas Ploch [EMAIL PROTECTED] wrote:
Do not forget:
- Time
- Personal Data (like birthdays, age)
The datetime module has perfectly good classes for holding date and
time values, and age sounds like an integer to me.
On Fri, 12 Jan 2007 17:15:56 +, Nick Maclaren wrote:
In article [EMAIL PROTECTED],
Facundo Batista [EMAIL PROTECTED] writes:
| Noud Aldenhoven wrote:
|
| There are a (small) couple of other issues where rational numbers could
be
| handy. That's because rational numbers are exact
Hello,
When I was programming in a mathematical project I began to wonder if python
supports rational numbers[1]. In a language like magma[2] it's not such a
problem. Does python supports something simular?
Greetings,
Noud Aldenhoven
--
:3 )~
[1] http://en.wikipedia.org/wiki/Rational_number
Noud Aldenhoven wrote:
When I was programming in a mathematical project I began to wonder if python
supports rational numbers[1]. In a language like magma[2] it's not such a
problem. Does python supports something simular?
Python does not have rational numbers.
There's a (rejected) PEP
On 1/11/07, Facundo Batista [EMAIL PROTECTED] wrote:
Python does not have rational numbers.
Ah, oke. Thank you, it seems I have enough information why they aren't
included in the core.
Question: Why do you say that it's a problem?
Well... Perhaps I word it wrong. It's not really a problem
Noud Aldenhoven wrote:
I'm a mathematician (in learning, with a bad feeling for English) and
don't trust irrational numbers in programming languages.
You may want to look at SAGE. It provides a ton of good mathematical code.
http://sage.scipy.org/sage/
--
Robert Kern
I have come to
In article [EMAIL PROTECTED],
Facundo Batista [EMAIL PROTECTED] writes:
| Noud Aldenhoven wrote:
|
| When I was programming in a mathematical project I began to wonder if
python
| supports rational numbers[1]. In a language like magma[2] it's not such a
| problem. Does python supports
Hello NG,
recently I was using Scheme and Ruby and was really nicely surprised
to find there support for the computing with rational numbers
for example this how it works in Ruby
mond:/pool/PROG/ruby # irb
irb(main):001:0
irb(main):002:0* require mathn
= true
irb(main):003:0 r = Rational(1,3
Schüle Daniel [EMAIL PROTECTED] writes:
does anybody know modules which make rational numbers available?
Try gmpy.mpq (google for gmpy).
and are there considerations to add them to the core, like
complex numbers (maybe in Python 3)
I don't think it's been discussed much.
--
http
Schüle Daniel [EMAIL PROTECTED] writes:
does anybody know modules which make rational numbers available?
and are there considerations to add them to the core, like
complex numbers (maybe in Python 3)
I think it's not likely. In Scheme, (/ 5 2) is the rational number
5/2, while in current
On Tue, 2006-01-17 at 11:22, Paul Rubin wrote:
Schüle Daniel [EMAIL PROTECTED] writes:
does anybody know modules which make rational numbers available?
Try gmpy.mpq (google for gmpy).
and are there considerations to add them to the core, like
complex numbers (maybe in Python 3)
I
Raymond Hettinger wrote:
For a simple example, convert both 10247448370872321 and
10247448370872319 from base ten to 4 digits of hex. The calculations
need to be carried out to 15 places of hex (or 17 places of decimal)
just to determine whether the fourth hex digit is a 7 or 8:
[Terry Hancock]
Needless to say, the conventional floating point numbers in Python
are actually stored as *binary*, which is why there is a decimal
module (which is new).
If you're going to be converting between bases anyway, it probably
makes little difference whether you are using
Raymond Hettinger wrote:
[Terry Hancock]
Needless to say, the conventional floating point numbers in Python
are actually stored as *binary*, which is why there is a decimal
module (which is new).
If you're going to be converting between bases anyway, it probably
makes little
For a simple example, convert both 10247448370872321 and
10247448370872319 from base ten to 4 digits of hex. The calculations
need to be carried out to 15 places of hex (or 17 places of decimal)
just to determine whether the fourth hex digit is a 7 or 8:
hex(10247448370872321)
On Monday 04 July 2005 06:11 am, Brian van den Broek wrote:
As a self-directed learning exercise I've been working on a script to
convert numbers to arbitrary bases. It aims to take any of whole
numbers (python ints, longs, or Decimals), rational numbers (n / m n,
m whole) and floating
numbers (python ints, longs, or Decimals), rational numbers (n / m n,
m whole) and floating points (the best I can do for reals), and
convert them to any base between 2 and 36, to desired precision.
I'm pretty close but I know I am not handling the precision quite
right. Nothing other than
), rational numbers (n / m n,
m whole) and floating points (the best I can do for reals), and
convert them to any base between 2 and 36, to desired precision.
Thanks to Terry and mensanator for the replies.
To consolidate, I respond to Terry in-line and then add some response
to mensanator
numbers (python ints, longs, or Decimals), rational numbers (n / m n,
m whole) and floating points (the best I can do for reals), and
convert them to any base between 2 and 36, to desired precision.
...
I've discovered empirically that I have to set getcontext.prec = 99 or
greater (i.e. x
, or Decimals), rational numbers (n / m n,
m whole) and floating points (the best I can do for reals), and
convert them to any base between 2 and 36, to desired precision.
I'm pretty close but I know I am not handling the precision quite
right. Nothing other than understanding hangs
64 matches
Mail list logo