A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-October/029348.html below:

PEP239 (Rational Numbers) Reference Implementation and new issues

[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issuesTim Peters tim.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 inexact

This avoids conflating exactness with representation, and, e.g.,

    #e#b1.001

is exactly 9/8 (although that Dr. Scheme allows a radix point in a binary
literal appears to be an extension of the Scheme std).  By default, a
numeric 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)
#t

I think this works very well.  The same rule about default exactness would
be appropriate for Python too, and an r suffix meaning what a #e prefix
means in Scheme would be a fine idea by my lights (the effect of an #i
prefix can be gotten via including a decimal point for decimal literals, and
inexact literals in other bases are rarely useful).




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