How can I represent -infinity
in C++, Java, etc.?
In my exercise, I need to initialize a variable with -infinity
to show that it\'s a very
You can't truly represent an infinite value because you've got to store it in a finite number of bits. There are symbolic versions of infinity in certain types (e.g. in the typical floating point specification), but it won't behave exactly like infinity in the strict sense. You'll need to include some additional logic in your program to emulate the behaviour you need.