isinteger - PHP check if is integer -


i have following calculation:

$this->count = float(44.28) $multiple = float(0.36) $calc = $this->count / $multiple; $calc = 44.28 / 0.36 = 123 

now want check if variable $calc integer (has decimals) or not.

i tried doing if(is_int()) {} doesn't work because $calc = (float)123.

also tried this-

if($calc == round($calc))  {     die('is integer'); }  else  {    die('is float); } 

but doesn't work because returns in every case 'is float'. in case above should'n true because 123 same 123 after rounding.

try-

if ((string)(int) $calc === (string)$calc) {   //it integer }else{   //it float } 

demo


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -