Max 7, negative 1, hi, 32 vs 64 bit
Hello, this is a Max 7 reboot of:https://cycling74.com/forums/1-representation-bug-in-max-6-1/
andhttps://cycling74.com/forums/max-6-1-64-bit-number-rendering-issue/
representation of -1 is inconsistent across 32/64 bit versions of Max and can be confusing/break patches. Here is an example of 64 bit Max 7.0.2 hi output from a Kensington Expert Pro trackball under OS x 10.10. I think it's apparent how this output can be hard to interpret:
hi: 7 8
hi: 7 6
hi: 7 3
hi: 7 0
hi: 7 4294967295
hi: 7 4294967292
hi: 7 4294967289
hi: 7 4294967288
element 7 is trackball horizontal delta.
Looks like the output negative values are using 4294967295 as -1, 4294967294 as -2, etc?
Maybe this has to do with whatever non-C74 APIs hi uses, and possibly a hi-related 32/64 bit issue.
But -1 issues are not limited to hi. The fist link above is a forum post about the phenomenon without use of a peripheral input:
Any chance of a fix for this?
In addition, regarding hi, maybe since Mavericks hi has been sometimes unable to detect device input when Max is in 32-bit mode under OS X. Perhaps this is a 32-bit limitation for Max?
In general hi barely works under Windows.
Is hi due for a redesign? Or an addition to the documentation outlining limitations?
This is still a problem with hi 64-bit, apparently. In El Capitan, no less.
Pretty clear what's going on: the bit representation of -1 with signed 32-bit ints is 1111 1111 1111 1111 1111 1111 1111 1111. When those bits are set in the low 32 bits of a 64-bit integer while leaving the higher bits clear (zero), the value represented is 4,294,967,295.
(Any introductory book on how computer arithmetic works will explain the gory details. But if you wanted to read a book you probably wouldn't be posting here?-)
Anyway, a simple workaround for values coming out of [hi] in a 64-bit world would be something like: send the output from [hi] through a [split 0 2147483647] and connect the right outlet to a [!- 4294967296]. The left outlet of the [split] and the outlet of the [!-] both get connected to whatever your further processing is.
I've rolled the above off the cuff of my sleeve (i.e., untested code written while I'm supposed to be making supper). But maybe it will work…
Peter,
Thanks for this.
As mentioned at the top of the thread the issue started with a clear understanding that this has to do with 32 v 64 bit number representation. Despite the clarification you provided I think there must still be the possibility that hi could interpret this particular incoming -1 correctly, in other words, there's a small -1 bug in Max 6 and Max 7.
In the case I was encountering I used the right outlet of sel 1 to t -1. This works because the messages were either -1 or 1, so easy to workaround.
As for reading books, you're right, I don't read many. As for posting here, I think, while forums could be more or less completely replaced by books, they serve a slightly different function.
If you've got a workaround, that's great.
What was going through my mind was a more general workaround, one that would work for all possible signed 32-bit values (at least, if my brain was working at the time).
The best workaround would, of course, if this got fixed. The problem's been around so long and reported so frequently that Cycling '74's engineers should be aware of it. I'm not sure why it should be particularly gnarly to sort out, but who knows?