|
Gigabyte Intel H81 Mini ITX DDR3 1600 LGA 1150 Motherboard GA-H81N |
Ran into a problem with boolean operations using the Go programming language today.
Program to demonstrate the problem can be found here. I'm just noting it here because where else can I put it? My Linux box rolled over and died the other day. I think the super fancy
Gigabyte motherboard died. I ordered
a replacment from the Amazon. Curious thing is
an exact replacement is available, but at five times the price. And
Gigabyte seems to be targeting big corporate customers, customers who are concerned about things like maintenance. The market must be fracturing more than I realized.
What is the boolean problem?
ReplyDeleteI had to rewrite
flag |= place[r+i][c]
as
flag = flag || place[r+i][c]
to get it to run, and then it output "No".
I think "grid [r+i][c]!=test" is always true because you're passing 1 as a parameter and the byte arrays are initialized to 0.
But I'm mainly a Java programmer; maybe I don't understand Go.
Turns out that the problem is that Go, like C, has two different OR operations. One for bitwise OR of integers and a logical OR for boolean variables. I was trying to use the bitwise operator on a boolean variable, and the compiler didn't like it. Seems kind of chickenshit to me, since you can use a plus sign (+) to concatenate strings. Go is a little more particular about variable typing than C, so it seems to me they could have simply eliminated the logical operators (&& and ||) and just used the same OR and AND symbols (& and |) for logical operations as they use for bitwise ops.
ReplyDeleteYeah, Java's the same way. "|" and "&" for integer types, "||" and "&&" for booleans. What I don't like is there's no "||=" or "&&=", but there is "|=" and "&=". That doesn't seem fair, since we use the boolean OR and AND about a hundred times more often than the integer OR and AND.
ReplyDeleteI think you've hit on it: it's unfair, and if it's unfair it must be discriminatory. We should protest. If we beat our tin cans loud enough we might be able to drum up a riot. Then we could have looting and we might even get on TV.
ReplyDelete