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
Use float. is_integer() to check if a float value is an integer. Call float. is_integer() to check if float represents an integer.
isInteger() method returns true if a value is an integer of the datatype Number. Otherwise it returns false .
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With