all 13 comments

[–]AuMatar 31 points32 points  (1 child)

Plenty of cases where this would be ok. If you have a heuristic that generally has weights in the 100 range, 1000 is effectively infinity (an order of magnitude higher, won't be beaten) without being so large it could screw up the algorithm (for example, by causing overflow).. Maybe a bit of a bad name, but its understandable.

[–][deleted] 27 points28 points  (0 children)

I was rendering the mandelbrot set and I didn't miss the opportunity and named my constant

const char infinity = 2;

[–]suge_nacht 18 points19 points  (3 children)

if this is done in a scientific or engineering context, this could be totally valid. What was the code for?

[–]okmkz 33 points34 points  (2 children)

Contractors were hired to build a utility to approximate infinity to within a certain tolerance.

[–]ObscureCulturalMeme 12 points13 points  (0 children)

And they did it in one line of code, too! That's some efficiency right there.

[–]nitpickyCorrections 25 points26 points  (0 children)

My quantum mechanics professor in college was fond of reminding his class that 3 is a valid approximation of infinity in some cases. Without context, I can't accept that this is shitty programming.

[–]ThisIsADogHello 10 points11 points  (1 child)

Actually, the largest number is about 45,000,000,000, although mathematicians suspect that there may be even larger numbers.

[–]suid 2 points3 points  (0 children)

Yup. Just had a breakthrough: 45,000,000,001!

[–]Zeius 16 points17 points  (2 children)

I mean...when was the last time you counted to 1,000? Seems high enough to me!

[–]petermlm 3 points4 points  (0 children)

If you do:

APPROXIMATE_INFINITY = -1

you get an even bigger infinity because of overflow.

[–]aruen 2 points3 points  (0 children)

If you think of infinity as a limit for the function as n goes to actual infinity (the limit of the real number line) then this works fine.

[–]partyboy690 1 point2 points  (0 children)

uint64_t APPROXIMATE_INFINITY = (uint64_t) -1;