Pep 238 Why new // operator (Non-integer Division)

Steve Williams stevewilliams at wwc.com
Sat Mar 17 21:29:28 EST 2001


Courageous wrote:

> >>All these changes make my head spin.  There is more to life than learning
> >>all the fine details in a computer language.  The fewer number of ways to do
> >>something the better.
> >
> >Just because the changes are being made doesn't mean you have to USE them.
>
> This isn't true; the moment you encounter code written by someone else,
> you DO have to use them. This simple principle is the magic of Python
> minimalism, and the primary driving reason why new Python programmers
> can become so effective so fast (IMO).
>
> C//

Adding 'line noise' symbols to a language doesn't help at all.  It doesn't even
address the underlying problem.

The difference between fixed/floating point arithmetic resides in the operands,
not the operators.

For example, consider fixed point(precision,scale) arithmetic for variables like

    A decimal(5,2)

    B decimal(3,1)

    C decimal(9,6)

You want to detect overflows when A = B / C exceeds 999.99.  You want to round
'appropriately' to .01 without knowing what an LSB is.  And so on.

This is garden-variety, every-day commercial arithmetic.  Your paycheck and tax
witholding are calculated this way.

Python, actually, can handle 'decimal arithmetic' very well:  define variables as
{name:(integer value,precision,scale)} with functions for add, subtract, multiply,
divide, move, compare, and display.

Let's reserve the 'line noise' infix operators for enhancing Python's complex
arithmetic to handle the octonions.





More information about the Python-list mailing list