4 ms·
To be slightly pedantic, C# gives you the option to throw an exception in that case (with either checked blocks or setting the CheckForOverflowUnderflow compile
by lazulicurio 4y ago
To be slightly pedantic, C# gives you the option to throw an exception in that case (with either checked blocks or setting the CheckForOverflowUnderflow compiler flag to true), but the default behavior is to allow overflow.
- nikeee 4y agoI was under the impression that they compile with /checked per default. TIL! Regardless of that flag, Math.Abs will throw an OverflowException: https://referencesource.microsoft.com/#mscorlib/system/math.cs,3f2bea7ad215b3cc,references https://referencesource.microsoft.com/#mscorlib/system/math....
- lazulicurio 4y agoThe default actually depends on project language IIRC. C# has overflow checking disabled by default, VB.net has it enabled by default. Not sure about F#.