2 ms·
Making int/int an illegal operation would solve some problems, but I doubt it would make things less confusing.
by dagw 10y ago
Making int/int an illegal operation would solve some problems, but I doubt it would make things less confusing.
- IshKebab 10y agoI think it would simplify things. All you need to remember is: / = normal division _/ = division then round down Then the compiler enforces all the hard-to-remember rules, i.e. that you can't to normal division on integers. Floats would support both.
- 1wd 10y agoI like the Pascal way of using named operators like `div` (and `mod`, `xor`, `shr`, `shl`, `sar` etc.). Much easier to remember, read and type. Why does everything have to be cryptic symbols? This also frees up those symbols for use in more frequently used constructs. How often do you actually use those bit fiddling operators nowadays?
- AnimalMuppet 10y agoI want / for division for the same reason that I want + for addition. (Pascal doesn't make you say 'plus'...)
- 1wd 10y agoPascal has / for real division, but div for (truncated) integer division.
- AnimalMuppet 10y agoSo it had + for "integer addition, but can overflow", and what for "real" addition? My point is that separating "real" division from integer division is... a bit artificial? Not totally mistaken - there are differences - and yet calling one "real" is going a bit too far. All of these models of arithmetic suffer from the limitations of their representation. In all cases, you'd better be aware of what those limitations are...