• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to convert hex value to int array?

 
Sara Jonasn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,

I have a big problem. I could not find any result by searching in google please help me.

I want convert a hex number like 02468aceeca86420 to a two dimension int array ? how can i do it?
 
Junilu Lacar
Bartender
Posts: 7595
53
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain how a hexadecimal representation of a number is supposed to be mapped to a two-dimensional array. I can imagine doing it with a one-dimensional array but can't see how to do it for two dimensions. What goes in rows and what goes in columns?
 
Sara Jonasn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:Please explain how a hexadecimal representation of a number is supposed to be mapped to a two-dimensional array. I can imagine doing it with a one-dimensional array but can't see how to do it for two dimensions. What goes in rows and what goes in columns?




yes you are right. how i can convert it to an one-dimensional int array?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first step is always to describe what you need to do in English (or any other natural language of your choice). pretend you have to explain to a child what needs to be done. If you said "put a hexadecimal number into a 2-d array", do you think a child would have any clue what to do?

I'm 44, and I don't understand what you need done. So try explaining it in detail.

Usually, once you can do that, writing the code is easy.
 
Sara Jonasn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a hex string like "02468aceeca86420 "
i want convert it to an integer array . This array contain 0,1 .Any character in this string must convert to a binary number and it must store in array.For Example this hex string 02468aceeca86420 must convert to this :00000010......... that all these 0 and 1 must store in integer array (1-D not 2-D).
 
Campbell Ritchie
Sheriff
Pie
Posts: 49793
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not very explicit. Do you mean you want to convert each hex digit into its corresponding 4 bits? And how do you intend to record those bits?
 
Henry Wong
author
Marshal
Pie
Posts: 21415
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:That is not very explicit. Do you mean you want to convert each hex digit into its corresponding 4 bits? And how do you intend to record those bits?


Sounds like it will be an integer array, where each member can hold either a zero or a one. Not very effiecient storage in my opinion.

However, the sizing should be easy. Since each hex digit is exactly four bits, the size of the array is simply the length of the string times four.

Henry
 
Campbell Ritchie
Sheriff
Pie
Posts: 49793
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can actually use a boolean[] to reduce the storage.


I have just invented the BitSet, only backwards!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic