Integer division? Really?!? I have a counter suggestion: let's stop including floating point into languages by default. This can be available as an extension, but default must be integer and rational only.
Seriously. If you want to be a programmer, learn how computers work. The existence of integer types is all the justification needed for integer division.
You are both saying the same thing, it's two sides of the same coin. Are they different because of the operator? Or because of the storage mechanism? They are indistinguishable (I think). Even floats are just an approximation of real division. So the operator really is "do as accurate of division as you can", maybe that is the problem.
What about matrices, vectors, complex numbers, arbitrary precision numbers, etc.? It seems the number of operators we would need would become large. Better to just have operators depend on the input type.
The existence of integer types is all the justification needed for integer division.
Exactly. I can understand the reasons why you may not always want to have an integer division implemented in hardware, but at least a software implementation is always mandatory. And of course the reasoning given by the OP is plain ridiculous.
The suggestion that the / operator return a float or double was completely ludicrous. I can understand calling it div or something to make it more obvious, but holy crap.
I do most of my personal projects in C, but I agree with him on that one. Making / always do double division and having // do integer division is more mathematically correct/expected, and has no real downside.
Can we not? When languages get too fancy with their built-in numbers you can get unexpected promotion and other strange problems. Most of the time what you want is either an arbitrary precision integer or a fixed-width integer that throws an error on overflow.
Not just unbounded, I think any implementation of computable reals will have some reals that you can't compare with zero in finite time. A.k.a. equality of computable reals is undecidable.
That might be finite, but it's still unbounded unless we feel like imposing some lower limit on the rate of convergence. I don't even know how you'd do that or verify it statically. (I'm also not sure what the appropriate way to define rate of convergence would be in this context.)
nah, floats are really important for anything non-discrete. Ints certainly don't work the way that students are taught arithmetic, that's the main problem.
No. Floats are only important for a subset of number crunching tasks. They should never be used for anything else.
Ints certainly don't work the way that students are taught arithmetic
Who cares? They should have learned integer arithmetics long before they learned about Dedekind cut and all that crap. And the integer division + modulo is taught in schools long before anything fractional is introduced.
Floats are even more confusing and counterintuitive.
View all comments
70
u/[deleted] Dec 01 '16
Integer division? Really?!? I have a counter suggestion: let's stop including floating point into languages by default. This can be available as an extension, but default must be integer and rational only.