3 ms·
I'd argue that in the case of your first example, C++ is correct. Promoting int to double in this case does not bother me whatsoever. (In fact, mathematically
by AnimalMuppet 11y ago
I'd argue that in the case of your first example, C++ is correct. Promoting int to double in this case does not bother me whatsoever. (In fact, mathematically, an integer is a real, though the reverse is not always true.
I will concede that the others are problematic...
- ajuc 11y agoIn 1 the problem is silently discarding double precision to float precision. I edited the example to be less confusing.
- AnimalMuppet 11y agoAh. Yes, I was confused; I thought the issue was the promotion of the 2 from int to floating point.
- ajuc 11y agoAlso I made an error - should have been *(1+a) = 1; Still bad but not as bad.
- AnimalMuppet 11y agoOr: 1[a] = 1;
- AnimalMuppet 11y agoAfter thinking about it a bit, that also is well-typed in C. (You can argue that it shouldn't be allowed, but that's a different argument than that the language is not strongly-typed because of that feature.)