4 ms·
> the == equality operator is a bitwise comparison With floats being the exception
by skitter 4y ago
> the == equality operator is a bitwise comparison
With floats being the exception
- masklinn 4y agoAnd strings being the second exception. And complex as they're basically a pair of floats. And transitively any array or struct containing one of the exceptions. So really, == is mostly not a bitwise comparison, when you think about it.
- Dylan16807 4y agoWhat do strings do with == that isn't bitwise over the contents?
- masklinn 4y agoCompare the contents of the actual buffer. If == on string was a bitwise comparison, it would be an identity check. But two different strings with the same content compare equal, meaning go dereferences the buffer pointer.
- Dylan16807 4y agoSo it is comparing the contents exactly, the same as with an array or struct? In that case strings aren't an exception, looking at contents is just how structs work.
- masklinn 4y agoOh hey, flying goalposts, cool.
- Dylan16807 4y agoThe hell are you talking about? I used the same phrasing both times.
- DonHopkins 4y agoYou're the one who brought up comparing the contents instead of just the types and pointers. The first pair of goalposts was the fixed size comparison of the (type, pointer) bits of the string object reference, the second pair of goalposts was the variable length and arbitrarily long contents including the bits that the two different string pointers refer to. The bits of a structure containing a string don't also include the contents of the string itself.
- Dylan16807 4y ago"any array or struct containing one of the exceptions" is already talking about comparing the contents instead of the types and pointers. I didn't bring up the idea, I just said strings did the same, and with everything doing the same thing it's not an exception to bitwise comparisons, it's a general rule for how to handle nesting. Floats are still an exception, but not the rest of that list.
- deleted 4y ago[deleted]