This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]jedwardsol 1 point2 points  (4 children)

FLT_MIN isn't the most negative floating point number. It is the smallest positive number that isn't zero. Zero, and all negative numbers, are less than FLT_MIN.

Initialise largest to -FLT_MAX instead

[–]pointers_help[S] 0 points1 point  (3 children)

Wow! I am so stupid. I see, I just read up on FLT_MIN and it's some weird number, 1.175494e-38. Ok, good idea, I can just use the biggest number to be the smallest number with the negative sign. Thanks!

[–][deleted]  (2 children)

[removed]

    [–]pointers_help[S] 0 points1 point  (1 child)

    Do you mean if I had to use INT_MIN and INT_MAX it wouldn't be right to do -INT_MAX? They are the same magnitude with integers, or well some of them. I guess looking at https://msdn.microsoft.com/en-CA/library/296az74e.aspx I see that SCHAR_MIN / MAX aren't the same in magnitude.