P
Paul Rubin
D'Arcy J.M. Cain said:Recheck the context. I was talking about the natural result, not
natural numbers.
The natural result of doing arithmetic with natural numbers is more
natural numbers.
D'Arcy J.M. Cain said:Recheck the context. I was talking about the natural result, not
natural numbers.
Paul Rubin said:
D'Arcy J.M. Cain said:Recheck the context. I was talking about the natural result, not
natural numbers.
Paul Rubin said:The natural result of doing arithmetic with natural numbers is more
natural numbers.
Ross Ridge said:D'Arcy said nothing about natural numbers, and bringing them up adds
nothing to this discussion.
The natural result of doing arithmetic with natural numbers is more
natural numbers.
Hallöchen!
Grant said:[...]
Nope. I would prefer that int OP int always produce an int.
And 2**-1?
Your formulation tries to suggest some sort of logical
consequence but in my opinion, it's still a mere matter of
taste and habits. I remember my first steps in C++ 12 years
ago when I tried to implement a couple of astronomical
formulae, always getting false results because C++ calculated
3/4=0.
I think the only real reason for people prefering int/int=int
is that computers can deal with inteters better than with
floats, resulting in int-only arithmetic in computer
languages. However, I don't consider this a particularly good
reason.
Integer division means integer result to me in a very real sense.
Grant said:Grant said:[...]
Nope. I would prefer that int OP int always produce an int.
And 2**-1?
An error.
Ross Ridge said:D'Arcy said nothing about natural numbers, and bringing them up adds
nothing to this discussion.
Paul Rubin said:The numbers D'Arcy is proposing to operate on that way are natural
numbers whether he says so or not.
Really, the "natural" division operation on integers, if there is one,
is divmod (which returns a quotient and remainder).
So, when you have five children over for a birthday party, and one cake,
do you say "Sorry kids, no cake for you: one cake divided by five is
zero"?
Of course you do, you big meanie. I think you catered for my 12th
birthday party.
I am really having a hard time accepting that "TRUTH (tm)" is determined
by election.
J. Cliff Dyer said:So do you believe that you should not be able to do natural division
without explicitly casting ints as floats, or is your concern just that
you want to still be able to to integer division simply?
Paul said:The natural result of doing arithmetic with natural numbers is more
natural numbers.
Grant said:Good one.![]()
I think the issue is whether this qualifies as "natural" division in the
first place. (For the record, I'm only semi-old-school.)
J. Clifford Dyer said:If the issue is that it should
remain an integer because that mimics how the computer works, than I
think it is worth pointing out that allowing a conversion to a long also
goes against how the computer works; the computer would have a register
overflow. If the issue is that in python the division operator has
always performed integer division, and should not change, then I think
we're talking about a philosophical opposition to Python 3 that goes far
deeper than just how integer division behaves.
At any rate, the whole argument is irrelevant--python already supports
floating point results for integer division, and that isn't going away,
but neither is integer division that always results in integer results,
so if you don't like getting floating point results, you never have to
use the / operator.
But I don't think that *was* the issue in the first place. The
issue is whether python's division should only yield integers
when given integer inputs. "Natural" is a polemical term no
matter who is using it in this argument, so lets drop it
altogether. If the issue is that it should remain an integer
because that mimics how the computer works, than I think it is
worth pointing out that allowing a conversion to a long also
goes against how the computer works;
the computer would have a register overflow. If the issue is
that in python the division operator has always performed
integer division, and should not change, then I think we're
talking about a philosophical opposition to Python 3 that goes
far deeper than just how integer division behaves.
At any rate, the whole argument is irrelevant
Certainly, I'd expect that if x and y are both integers and x is an
exact multiple of y, then x/y will be computable and not overflow.
But try computing 10**5000 / 10**4000 under future division (that is
supposed to give a float).
No, the discussion has been about the behaviour of the division operator
in Python when used with Python's integral and floating-point data types.
These data types include many numbers that are not natural numbers.
J. Cliff Dyer wrote:
Or Jo thinks // is a typo, and helpfully "fixes" it.
Mark said:And smaller numbers are problematic too:
9999999999.9999981
This despite the fact that the quotient *is* exactly representable
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.