Bit conversion operations in PHP
- by Goro
Hello,
I find myself in need of performing bit-level conversion on variables in PHP. In more detail, I have a bit stream that is read as an integer by hardware, and I need to do some operations on the bits to make it into what its actually supposed to be (a float). I have to do this a few times for different formats, and the functionality I need is
Being able to select and move individual bits in a variable
Being able to cast statically one type of variable to the other (ie. int to float)
I know php natively supports bitwise AND, OR, etc, and shift operations, but I was wondering if:
there may already be a library in php that does this sort of thing
I would be better off with delegating the calculations to some other language
Thanks,