Byte Array for storing hexa decimal value

i need to convert one variable into equivalent hexa decimal number. and
want to store it in one array…In java i had use Byte array for storing
the hexa decimal value… IN ruby is der any array equivalent to byte
array(java)?

Hi,

There are no “hexadecimal numbers”. An integer is an integer, but it can
have different representations (binary, octal, hexadecimal etc.).

So you simply put the integers into an Array, and whenever you display
them, you use the hexadecimal representation. This can be done with the
to_s method:

91.to_s(16)

The 16 specifies the base (16 for hexadecimal, 2 for binary etc.).

By the way, I’m not even sure what you mean by “byte array”. The byte
type in Java is simply a shortened integer. It has nothing to do with
hexadecimal.

v Mahes karthick wrote in post #1063507:

i need to convert one variable into equivalent hexa decimal number. and
want to store it in one array…In java i had use Byte array for storing
the hexa decimal value… IN ruby is der any array equivalent to byte
array(java)?

Hi,

If you are on Windows, if you want the same “kind of storage”, you can
use RTensor with type ‘char’ (signed byte) or ‘uchar’ (unsigned byte).
But if you want hexadecimal number, it is just a representation, as Jan
E. has pointed out.

Regards,

Bill