Test if number is integer

Hey guys, I know there are various ways of testing if a number is an integer or not, but what's the best way to do it? The sort of "official" IsInteger method kinda thing.

Thanks guys!!
developingprogrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

duttcomCommented:
ISNUMERIC is a boolean property which will return 1 if the field contains a number (not specifically an interger though) and 0 if it is not.
BitsqueezerCommented:
Hi,

I would use "If Int(MyNumber) = MyNumber".

Cheers,

Christian

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
duttcomCommented:
Der. I should have read the question more closely. Christian is spot-on.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

developingprogrammerAuthor Commented:
Cool thanks Christian!! = )) thanks duttcom too!!

Hrmm duttcom I also think that true should equal to 1, but somehow in Access they set it to -1.

Why -1? I'm no sure but maybe because it doesn't want to use the positive bits. Hrmm no wait a Boolean is a value type by itself. So it takes one bit I believe. So why when we convert it to a number it uses 2 bits? One bit for sign, one bit for the value. Hrmm I'm not sure. Ok lets ask Christian! (P.S. duttcom, Christian knows EVERYTHING about programming. Hrmm and that's probably an understatement already haha. I'm very fortunate to have him help me out all the way!! = ))))   )

Christian! If you don't mind, could you share your thoughts on why true is -1 instead of 1 when I cint it? Seems like Boolean is taking 2 bits!
BitsqueezerCommented:
Hi,

;-))
No, I absolutely don't know anything about programming...:-)

But this one I can answer. Here you find a type description:
http://msdn.microsoft.com/en-us/library/aa263420%28v=vs.60%29.aspx

Surprisingly a boolean value is not a bit, but a word (=16 bit). The difference between True and False is that any positive value in a memory cell is handled as "0000 0000 0000 0000" as bit code and a negative (beginning with -1) would be "1111 1111 1111 1111". That's the difference between True and False: Any bit = 0 is False, any bit = 1 is True.
That can be handled more easily when applying operations with this value and so it's faster. It is a lot more memory needed as only one bit. SQL Server for example really uses 1 bit and so the value is 1 and 0. But in result you cannot calculate with a bit value in SQL Server, you must convert it to integer first.

It would cost a lot more performance if a programming language would really only use 1 bit to hold a boolean value although possible: You must use extra logic like AND and OR to set or delete a specific bit because the minimum you can address is a byte. In C64 days when we had only 64KB memory we've done that and saved flag states inside of one byte (so we had 8 bits = 8 flags in one byte). Today memory is no issue so why should the programming language take care of it?

Cheers,

Christian
developingprogrammerAuthor Commented:
WHAO! see duttcom whaddiya say? haha = PP i even need to re-read this and figure out the sub-concepts it covers! benefits of bitwise operations using 16 bit variable (but that's cause i'm at beginner level and soon to be familiar with these concepts!!

(to Christian - reading reading reading reading reading)

hahaha = )) thanks Christian!! let me digest this!! = ))
BitsqueezerCommented:
Hi,

maybe I should also add that the highest bit (the one at the leftmost position in a word or long) is the one which is handled as indicator if a number is positive or negative. Think a little bit about why a long datatype can only have numbers between 0 and 2,147,483,648 and not 4,294,967,296 although it has 32 bits...;-)

Cheers,

Christian
developingprogrammerAuthor Commented:
cool thanks Christian! i'll go through this again next week!! = ))
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.