Results 1 to 3 of 3
Thread: get binary value
- 06-14-2008, 06:11 AM #1
Member
- Join Date
- Jun 2008
- Posts
- 2
- Rep Power
- 0
get binary value
Hi all
Consider that I have a string in hex like this:
Now I wanna convert it to binary, then I wanna have each digit single. For example, binary value for above string is:Java Code:3020058020C00004
And I wanna haveJava Code:11000000100000000001011000000000100000110000000000000000000100
How can I achieve this?Java Code:1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
- 06-14-2008, 06:56 AM #2
You can use:
to parse the input String to a long and then to transform it into a binary string. In th end you display the digits one by one.Java Code:// Long: static long parseLong(String s, int radix) long l = Long.parseLong("3020058020C00004", 16); // Long: static String toBinaryString(long i) String b = Long.toBinaryString(l); // String: char charAt(int index) for (int i = 0; i < b.length(); i++) { System.out.println(b.charAt(i)); }Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
-
Similar Threads
-
binary conversion
By thamizhisai in forum New To JavaReplies: 3Last Post: 04-29-2008, 11:55 AM -
Binary Addition
By Deo Favente in forum Advanced JavaReplies: 11Last Post: 04-24-2008, 05:34 AM -
Binary Search in Java
By Java Tip in forum AlgorithmsReplies: 0Last Post: 04-15-2008, 07:43 PM -
JSP- Binary output stream
By Java Tip in forum Java TipReplies: 0Last Post: 01-29-2008, 09:06 AM -
binary search
By tranceluv in forum New To JavaReplies: 10Last Post: 01-14-2008, 07:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks