49
you are viewing a single comment's thread
view the rest of the comments
[-] kane@programming.dev 10 points 2 years ago

I always figured this was a nice joke but obviously not code that would ever actually be written by someone... Then I ran into this millimeter to inch conversion code in production this past month:

if (isNaN(mm)) return 0;
if (mm == 6) {
    inch = 0.125;
}
else if (mm == 8) inch = 0.25;
else if (mm == 10) inch = 0.375;
else if (mm == 15) inch = 0.5;
else if (mm == 20) inch = 0.75;
else if (mm == 25) inch = 1;
else if (mm == 30) inch = 1.25;
else if (mm == 40) inch = 1.5;
else if (mm == 50) inch = 2;
else if (mm == 60) inch = 2.5;
else if (mm == 80) inch = 3;
else if (mm == 90) inch = 3.5;
else if (mm == 100) inch = 4;
...
[-] ZILtoid1991@kbin.social 2 points 2 years ago

Even worse is, that the accurate conversion to one inch is 25.4mm.

[-] Beanie@programming.dev 2 points 2 years ago

even worse, the first if statement randomly has brackets while none of the others do

this post was submitted on 13 Jun 2023
49 points (96.2% liked)

Programmer Humor

19817 readers
59 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS