Reputation: 4870
I have a simple function as defined below:
if(currentValue < smallestValue)
{
smallestValue = currentValue;
}
What can I initialize smallestValue to so it will always be greater than the first currentValue?
Upvotes: 0
Views: 57
Reputation: 85779
By this rule: CurrentValue can be any real number, use Double.MAX_VALUE
:
double smallestValue = Double.MAX_VALUE;
But the second rule negates the previous: All my values are ints, so use Integer.MAX_VALUE
int smallestValue = Integer.MAX_VALUE;
Upvotes: 1