7 ms·
> It uses the mathematical division operator for something that doesn't behave in that way. Floating point does not behave in a mathematical way, either.[1][2]
by zamalek 10y ago
> It uses the mathematical division operator for something that doesn't behave in that way.
Floating point does not behave in a mathematical way, either.[1][2] Unless your language uses fractional representation using big integers for real numbers.
> that the pre/post increment aren't confusing
The operator and retrieval of the variable are two separate operations that occur in the order that you read them. None less trivial than "I" before "E" except after "C".
[1]: https://en.wikipedia.org/wiki/Single-precision_floating-point_format https://en.wikipedia.org/wiki/Single-precision_floating-poin...
[2]: https://en.wikipedia.org/wiki/Arithmetic_underflow https://en.wikipedia.org/wiki/Arithmetic_underflow
- IshKebab 10y ago> Floating point does not behave in a mathematical way It approximately does. The only common way that newbies would get tripped up is something like (3 * 1/3) != 3. Maybe that is a case for not allowing == operator to operate on floats (use a function/keyword instead), but I think that may be a step too far.
- vonmoltke 10y agoI don't think that is a step too far. When I was writing embedded code, == and != were prohibited for floating-point values. I support such a rule in general.
- krylon 10y agoYears ago, I worked on software that dealt with computational geometry a lot, and I quickly found out the hard way that the equality operator is pretty much useless for floating point values. On the other hand, that is a property of floating point numbers, regardless of what language one uses.
- dragonwriter 10y ago> On the other hand, that is a property of floating point numbers, regardless of what language one uses. That's true, but, OTOH, having floating point rather than an exact representation be the default representation for values represented as decimal literals, and the only non-integer type supported by convenient operators is a language-specific "feature" of C that many other languages don't share. (Though, to be fair, there are also many newer and popular languages that do share both, and more just the first, of those features.)
- seagreen 10y agoPersonally, I like my addition associative, but you do you. EDIT: Also I like my numbers reflexive.
- xorxornop 10y agoYeah, and integer division behaves approximately to real division, too.