1

I have a targetDataLine open...

byte[] bytes = new byte[line.getBufferSize() / 5];
line.read(bytes, 0, bytes.length);

The bytes array is in hex, how do I get it's contents to be represented as decimal values?

000
  • 26,951
  • 10
  • 71
  • 101
Riptyde4
  • 5,134
  • 8
  • 30
  • 57

2 Answers2

1
int decValue = Integer.parseInt(hexString, 16);

Resources: http://www.tutorialspoint.com/java/number_parseint.htm

000
  • 26,951
  • 10
  • 71
  • 101
0

Unsure of the OP's posting language.

In Python, if you have an array and you want to get the decimal values of the bytes, you could loop through and use ord() to get the decimal representation.

If you had to convert from an actual array containing hex values, then you can do the conversion as per this StackOverflow posting:

Convert hex string to int in Python

Community
  • 1
  • 1
Wing Tang Wong
  • 802
  • 4
  • 10