Bin, hex and oct

Xojo’s BIN, HEX and OCT methods and their new counterparts, ToBinary, ToHex, and ToOctal should do a better job than they do.

If you pass in an 8 bit value you _may_ get an 8 bit binary representation back – or not. And this is true for ALL numeric types. The string you get back may not represent the full value esp if the upper bits are 0. This can be a problem sometimes especially if you’re trying to debug an algorithm that flips bits and you want to see all of them in a string representation (see this bug report)

If you’re trying to use the newer API 2 style then you’ll fnd that single and double values have no ToBinary, ToHex, or ToOctal extensions (see this bug report )

And BIN, HEX and OCT do not work on currency values and it also has no extension methods (see this bug report)

So to fill this gap and fix these shortcomings I have created a module that you can add to your projects that will give you the proper representations AND that will allow you to convert a currency to binary, hex or octal and then convert that back to a currency.

Enjoy !

One Reply to “Bin, hex and oct”

Comments are closed.