Sunday, November 26, 2006

Arbitrary precision types for .NET (and some musings)

I came up today to this article that describes two new arbitrary precision types for .NET. One is an Integer, and the other a Decimal (I think it is not correct to call it a Double as in the title).

Although I don't often use arbitrary precision math, this is a welcome addition. It is also interesting to think how nicely such a feature can integrate in the existing framework, given generics and the unified type system.

Speaking of which... I found recently that the Parse and TryParse methods that numeric value types share do not belong to a common generic interface, reducing its usefulness in some scenarios.

I hope we will someday see something like IParseable<T> together with IComparable, IEquatable, IConvertible and IFormattable.

And what about the MinValue and MaxValue constants? Shouldn't they belong to a common type?

There is also this internal class called Number that seems to hold the implementation of methods of every numeric type. I wonder if they could somehow introduce a Number class as a common ancestor without breaking value types rules.

2 comments:

Diego said...

MinValue and MaxValue properties could belong to a "scalar" type because DateTime also have them.

Diego said...

When I wrote all this stuff, I failed to remember that I was talking about static members.

Moving to MSDN

I haven't decided yet, but it is very likely that I will stop blogging here for some time. For some background, I have moved to the sate...