Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
testing for a WHOLE number!
Old 10-21-2008, 04:04 PM testing for a WHOLE number!
pealo86's Avatar
Super Spam Talker

Posts: 850
Name: Matt Pealing
Location: England, north west
Trades: 0
Im trying to test a script for a whole number value of a variable but can't seem to get my head around it.

Ive tried testing for it using the isNaN() and typeof() functions but both just class integer and double values as 'numbers'!

Is there a relatively simple way around this?

Thanks to anyone who can help!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 10-21-2008, 04:52 PM Re: testing for a WHOLE number!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
There is a round method in the Math() object that works like this:
Code:
var x=1.1;
x=Math.round(x);
alert(x);
will alert 1.
To see if a number is a whole number, you simply compare it to a rounded version of itself.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 10-24-2008, 12:00 PM Re: testing for a WHOLE number!
pealo86's Avatar
Super Spam Talker

Posts: 850
Name: Matt Pealing
Location: England, north west
Trades: 0
Ahhh I see what you mean! Thanks
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 10-24-2008, 12:23 PM Re: testing for a WHOLE number!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You're welcome
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to testing for a WHOLE number!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34175 seconds with 12 queries