-
Integer infinity?
Hey,
For comparing purposes I want to make an integer essentially "infinity" (meaning any int compared to it will be smaller). I know math.h has a float infinity, but trying to cast it as an int make the compiler freak out. Is there any way to make an integer "infinity"??
Thanks!!
-
No, there is no such thing.
However you don't need such a thing to obtain code that operates as if "any int compared to it will be smaller". You can for example use a longer integer type than the type in the data you are finding the maximum of. Or you can use a boolean flag. Or you can simply use the largest value the integer can hold in some cases, since if the maximum is equal to that then the answer is already correct.
If that doesn't give you enough information then you'll need to post a code sample of where you want to use this idea.