Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check for inf - Objective-C

Tags:

What is the method for testing whether a double (or integer) is infinity, for example when 1/0 operation is performed?

isfinite(n) does not seem to work.

like image 384
John67 Avatar asked Sep 05 '11 00:09

John67


1 Answers

You may check

if(d == INFINITY) {} 

or

if(d > DBL_MAX) {} 

INFINITY is a constant float expression defined in math.h representing positive infinity;
DBL_MAX is a constant defined in float.h representing the largest double that can be represented.

Check also here

like image 97
Manlio Avatar answered Sep 28 '22 07:09

Manlio