Hi, I imagine this is simply an issue in which I am not finding the correct formula option but how does one perform basic bitwise operations in a JMP formula?
e.g. Here's an example Python example that I would like to replicate in JMP: lambda x: ((((x>>1)&0x1))<<2)
thanks, Ross
JMP has no native bitwise operators. In your example, I'd try this
// untested code for (((x>>1)&0x1))<<2
f = function( { x },
( mod( floor( x / 2 ), 2 ) == 1 ) * 4
}x>>1 (right shift 1) divides x by 2, &1 keeps only the least bit (zero/one, even/odd), and <<2 (left shift 2) multiplies by 4. (Assuming python works like C and I haven't forgotten...)
If you have a lot of these, with peculiar bit positions, etc, you might want to look for a bit manipulation library. The only one I'm aware of is in 7 things to know about Twitter and may not be very friendly (BITS.jsl file in the zip file). I don't remember exactly what it does, but it looks like it is solving the problem by turning a number into a character string of 32 ones and zeros, then combining the strings using AND/OR/etc logic rules. It is probably missing any operations that were not needed. And I'm pretty sure the HTTPRequest function would make that code much easier now.
Negative numbers can be really weird when doing right shifts. The sign bit can be trouble.