Cedric Adjih wrote: > > M.-A. Lemburg <mal at lemburg.com> wrote: > > Paul Prescod wrote: > >> > >> "M.-A. Lemburg" wrote: > >> > > >> >... > >> > > >> > from mx.Number import * > >> > f = Float(3.141) > >> > r1 = Rational(3.141) > >> > r2 = Rational(2, 3) > >> > i = Integer("1231231231231231231231231") > >> > >> Wouldn't you more often make a rational from a string instead of a > >> float? The float loses precision and the rational loses performance so > >> you've got the worst of both worlds. :) > > > > The normal way to create a Rational is to write Rational(2, 3). > > The next release will also have a string parser for rational > > numbers (in the format "2/3" and probably "12 2/3" too). > ^^^^^^ > ^^^^^^ > Just a note: > This one is cultural and could generate lots of confusion. > The only way I can parse it is 12*2/3 (I'm French). > No French book (I know of) uses this notation: 38/3 or 12+2/3 > is used instead. It's as if you wrote the complex number > 3+4j as "3 4j" (look: "3 4j + 4 5j * 1 7j", hmmm...). The notation is quite common in financial business and mathematics. I agree that it can be confusing, but since the parser will only accept a single rational in the string, I believe that at least when using Rational() this behaviour can be accepted. The situation is different for literals, of course... -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4