By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

base numeric type?

P: n/a
Hi all...

I'm playing around experimenting with Extensions and R&D'ing what's new.

There's a procedure I would like to add to numbers, and I was wondering, is
there any "base" number type, that I could put an extension on, as opposed
to manually adding it to all the numeric types...
decimal, double, single, long, short, etc... ??

Arthur Dent.

Dec 7 '07 #1
Share this Question
Share on Google+
2 Replies

P: n/a

What is wrong with the for all base type object, normal can from that any
numeric type be converted as long as it does not conflict with the receiving
field? Convert from int to double goes, from double to integer can conflict.

I understand that it is not a direct answer on your question, however I use
in that often the sample of the car I had. It had a square steeringwheel
(Austin Allegro). I found it great, it was something different and probably
from the future. In fact it had only problems; To much to tell here. Square
wheels seldom function, however they are invented again and again and again.

And don't tell converting takes time, all new steering wheels thake behind
the scene probably much more time.

Just my idea reading your message


Dec 7 '07 #2

P: n/a
"Arthur Dent" <hi*********************@yahoo.comschrieb
Most important last: What are you trying to do with these types?

Well, for example, take a inanely simple numeric function,
"IsPositive". I know this is not something you'd actually code,
because it is SO simple, but as an example.

I'd like to take my new function, and be able to do something akin

<Extension()Public Function IsPositive(target As
anyNumericType) As Boolean

As opposed to having to do this...

<Extension()Public Function IsPositive(target As Short) As
Boolean <Extension()Public Function IsPositive(target As
Integer) As Boolean <Extension()Public Function
IsPositive(target As Long) As Boolean <Extension()Public
Function IsPositive(target As Single) As Boolean <Extension()>
Public Function IsPositive(target As Double) As Boolean <Extension()>
Public Function IsPositive(target As Decimal) As

It would be very nice if all the "number" types did implement some
common INumber interface, but as far as I know, they don't, do they?
No, only those that you see in the object browser.

Why not simply use ">0" in this case (without using Extensions)? Or
Math.Sign which is overloaded but already there. What else do you want to do
with "target"?

Dec 7 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.