[Mono-list] Native number types but not general number type?

Dan Shryock dan.shryock at gmail.com
Wed Feb 25 02:02:30 UTC 2015

>From my understanding, it comes down to generalizing over number
operations, not about creating a number type hierarchy.

You could create a type hierarchy, but you wouldn't be able to use natural
operators, you'd need to use interface methods like a.Add(b).

I'm pretty sure that you could create an interface that represents the
major number operations, and then create structs that implement that
interface and wrap the main number types without touching anything in the
runtime like native types needed to do.

On Tue, Feb 24, 2015 at 1:31 PM Michael McGlothlin <
mike.mcglothlin at gmail.com> wrote:

> With the addition of native number types I have returned to an old line of
> thought about why C# doesn't have a general Number type with other number
> types in some sort of hierarchy under it.
> Obviously there are times when using a very specific number type is
> important for performance or compatibility but usually I don't really care.
> I probably don't care if the number is represented as 32 bits or 64 bits,
> if it's signed or not, if it is whole numbers or fractional, etc. So long
> as the behavior is correct when casting to a more specific type I'd rather
> it just work with the least amount of effort.
> Likewise I'd like to more easily use lossless numbers of unlimited size,
> including fractional values, when needed and easy manipulation of numbers
> into different representations (such as byte order, different ways of
> storing the sign, etc). Something similar to changing text encodings.
> A general number type seems it'd ease portability even more than native
> types. It was mentioned that Mono may push for these native types to made
> standard. Is there a technical reason a general number type couldn't be, or
> shouldn't be, introduced? Not asking anyone to actually doing it so much as
> trying to understand the problem.
> Sent from my iPad
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20150225/47013c8c/attachment.html>

More information about the Mono-list mailing list