Movatterモバイル変換


[0]ホーム

URL:


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

Delaney, Timothytdelaney 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 divisionnotation in favour of 'mod' (since this would be a major incompatiblelanguage 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 atthis 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-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp