File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to convert hex value to int array? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to convert hex value to int array?" Watch "how to convert hex value to int array?" New topic
Author

how to convert hex value to int array?

Sara Jonasn
Greenhorn

Joined: Jan 10, 2013
Posts: 9
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

Joined: Feb 26, 2001
Posts: 4456
    
    6

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?


Junilu - [How to Ask Questions] [How to Answer Questions]
Sara Jonasn
Greenhorn

Joined: Jan 10, 2013
Posts: 9
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

Joined: Oct 02, 2003
Posts: 11256
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Sara Jonasn
Greenhorn

Joined: Jan 10, 2013
Posts: 9
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

Joined: Oct 13, 2005
Posts: 38481
    
  23
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
Sheriff

Joined: Sep 28, 2004
Posts: 18760
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38481
    
  23
You can actually use a boolean[] to reduce the storage.


I have just invented the BitSet, only backwards!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to convert hex value to int array?