2 ms·
> while simultaneously having to worry about low-level problems like integer overflows Integer overflows are exactly the same in Java and C# as they are in C.
by _pmf_ 13y ago
> while simultaneously having to worry about low-level problems like integer overflows
Integer overflows are exactly the same in Java and C# as they are in C.
- jasomill 13y agoNo! Signed integer overflow in C/C++ is undefined. In other words, the language specifications permit implementations to do anything whatsoever[1]. This is emphatically not the case with either Java or C#. As an example, per the spec, with respect to C# integer multiplication, In a checked context, if the product is outside the range of the result type, a System.OverflowException is thrown. In an unchecked context, overflows are not reported and any significant high-order bits outside the range of the result type are discarded. In other words, while integer overflow isn't necessarily checked, unlike C/C++, C# isn't allowed to corrupt memory, violate runtime security guarantees, format your hard drive, threaten the President, or launch a video game[2] on integer overflow. [1] http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html http://blog.llvm.org/2011/05/what-every-c-programmer-should-... [2] http://feross.org/gcc-ownage/ http://feross.org/gcc-ownage/