Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if float value is integer

In Objective C, how can I check if value is integer number like 2.000 , 3.000, 8.000 stored as a float, and not a fraction like 2.456, 3.578

like image 542
sourabhkumbhar Avatar asked Nov 16 '13 13:11

sourabhkumbhar


People also ask

How do you check if a float is an integer Python?

Use float. is_integer() to check if a float value is an integer. Call float. is_integer() to check if float represents an integer.

How do you check if a value is an integer?

isInteger() method returns true if a value is an integer of the datatype Number. Otherwise it returns false .

Is float an integer?

Integers and floats are two different kinds of numerical data. An integer (more commonly called an int) is a number without a decimal point. A float is a floating-point number, which means it is a number that has a decimal place. Floats are used when more precision is needed.


1 Answers

I think you're asking how to find out if a number stored as a float is an integer. There are a number of techniques. Here's one:

if(fVal == floorf(fVal))
    ... // do something
like image 190
godel9 Avatar answered Oct 20 '22 00:10

godel9