Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issues

Tim Peterstim.one@comcast.net
Mon, 07 Oct 2002 22:51:55 -0400


Noting that Scheme has two sets of optional numeric literal prefixes:    #b #o #d #h  number is binary, octal, decimal (the default), or hex    #e #i        number is exact or inexactThis avoids conflating exactness with representation, and, e.g.,    #e#b1.001is exactly 9/8 (although that Dr. Scheme allows a radix point in a binaryliteral appears to be an extension of the Scheme std).  By default, anumeric literal is inexect iff it contains a radix point or an exponent, but#e or #i can override that.> (exact? 2)#t> (exact? #i2)#f> (exact? 6.02e23)#f> (exact? #e6.02e23)#tI think this works very well.  The same rule about default exactness wouldbe appropriate for Python too, and an r suffix meaning what a #e prefixmeans in Scheme would be a fine idea by my lights (the effect of an #iprefix can be gotten via including a decimal point for decimal literals, andinexact literals in other bases are rarely useful).


[8]ページ先頭

©2009-2025 Movatter.jp