A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/065826.html below:

ANN: Experimental Number Types (Integer, Rational, Floats)

ANN: Experimental Number Types (Integer, Rational, Floats)Delaney, Timothy tdelaney at avaya.com
Mon Apr 23 20:25:15 EDT 2001
> > > 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...

Of course, we should probably aim for a notation which is consistent *now*.

12 2/3 - ambguous across cultures.

38/3   - not ambiguous, but falls into the problem of integer truncation.
Nevertheless, I would prefer this notation, and deprecate integer division
notation in favour of 'mod' (since this would be a major incompatible
language change anyway, might as well make a new keyword at the same time
;).

12+2/3 - not ambiguous and valid if the above is valid (integer + rational),
I would probably want the compiler to start rolling literals together at
this point... otherwise there would be 2 runtime calculations going on
(division to form rational, then addition of integer).

Tim Delaney


More information about the Python-list mailing list

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