Re:How the .NET Runtime Loads a Type
by louthy on Friday June 16, 2017 @07:42AM
(#14568094)
Here's an ad-hoc polymorphic way of dealing with numeric types in C# without the boxing that would be caused by using an IArithmetic interface:
[ Parent
| on HN ]
Re:How the .NET Runtime Loads a Type
by colejohnson66 on Friday June 16, 2017 @04:05PM
(#14572231)
That doesn't account for overflow, though...
Sorry, I don't follow?
Re:How the .NET Runtime Loads a Type
by colejohnson66 on Friday June 16, 2017 @10:16PM
(#14573932)
The .NET implementation detects overflow and reports it back. This doesn't.
This:
var x = DoubleIt<NumInt, int>(Int32.MaxValue); // 20
Performs exactly the same as this: var a = Int32.MaxValue;
var b = Int32.MaxValue;
var c = a + b;
DoubleIt calls NumInt.Add which invokes the same code, why wouldn't it work in exactly the same way?