WW 719: Project Sous Vide

Beep boop - this is a robot. A new show has been posted to TWiT…

What are your thoughts about today’s show? We’d love to hear from you!

It would be interesting to know if Microsoft’s JDK can finally do math.

I wrote a program in J++ 1.1 and 6.0, but it never worked, so I created a bug report with Microsoft, but I never heard a reply. I tried it a couple years later and it still didn’t work.

void main() {
    int a, b, x, y;
    a = b = 1;
    while 1 {
        x += a;
        y += b;
        if(x > 100) { a = -1;}
        if(x < 0) {a = 1;}
        if(y > 500){b = -1;}
        if(y < 0) {b = 1;}
        System.out.println("X " + x + ", Y " +y);
    }
}

This should run X up to 100 and back down to 0 and Y up to 1000 and down to zero and back up again. But the math doesn’t work.

x += a is the equivalent of x = x + a
If a is 1, x should be incremented. If a is -1, x should be decremented. That works fine in Visual Basic, C, C#, PHP etc. Visual J++ ignores the sign and just keeps incrementing x and y, regardless of whether a and b are 1 or -1. Using a debugger, I confirmed that the if was working and a and b were switching to -1, but J++ just kept incrementing x and y.

In the end, I ended up doing:
if(a == 1) {x = x + 1;} else {x = x - 1;}

1 Like