jermaindefoe Posted November 23, 2009 Share Posted November 23, 2009 would % 1 == 0 be a good check for a whole number? and is there a method for checking is a number? regards Quote Link to comment https://forums.phpfreaks.com/topic/182612-check-for-is-a-whole-number-and-is-aa-number/ Share on other sites More sharing options...
monkeytooth Posted November 23, 2009 Share Posted November 23, 2009 is_numeric would be a method to check if a string is a number. but what do you mean exactly by whole number? Quote Link to comment https://forums.phpfreaks.com/topic/182612-check-for-is-a-whole-number-and-is-aa-number/#findComment-963815 Share on other sites More sharing options...
Mchl Posted November 23, 2009 Share Posted November 23, 2009 is_int Quote Link to comment https://forums.phpfreaks.com/topic/182612-check-for-is-a-whole-number-and-is-aa-number/#findComment-963816 Share on other sites More sharing options...
Daniel0 Posted November 23, 2009 Share Posted November 23, 2009 would % 1 == 0 be a good check for a whole number? No. In fact it won't work. 1.5 % 1 == 0 is true because 1.5 is implicitly casted to int. $n % 1 == 0 is a tautology in PHP even for floating point numbers. but what do you mean exactly by whole number? A whole number is an integer, i.e. a number without a fractional part. Quote Link to comment https://forums.phpfreaks.com/topic/182612-check-for-is-a-whole-number-and-is-aa-number/#findComment-963817 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.