Jump to content

check for is a whole number and is aa number


jermaindefoe

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.