Movatterモバイル変換


[0]ホーム

URL:


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

Cedric Adjihadjih at crepuscule.com
Sat Apr 21 06:52:35 EDT 2001


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/3is used instead. It's as if you wrote the complex number3+4j as "3 4j" (look: "3 4j + 4 5j * 1 7j", hmmm...).-- Cedric


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp