Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-14-2008, 08:11 AM
Member
 
Join Date: Jun 2008
Posts: 1
rushenas is on a distinguished road
get binary value
Hi all
Consider that I have a string in hex like this:
Code:
3020058020C00004
Now I wanna convert it to binary, then I wanna have each digit single. For example, binary value for above string is:
Code:
11000000100000000001011000000000100000110000000000000000000100
And I wanna have
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
How can I achieve this?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-14-2008, 08:56 AM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 191
danielstoner is on a distinguished road
You can use:

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)); }
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.
__________________
Daniel @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-14-2008, 03:51 PM
Fubarable's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 899
Fubarable is on a distinguished road
cross-posted in the Sun Java forums.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
binary conversion thamizhisai New To Java 3 04-29-2008 01:55 PM
Binary Addition Deo Favente Advanced Java 11 04-24-2008 07:34 AM
Binary Search in Java Java Tip Algorithms 0 04-15-2008 09:43 PM
JSP- Binary output stream Java Tip Java Tips 0 01-29-2008 11:06 AM
binary search tranceluv New To Java 10 01-14-2008 09:13 PM


All times are GMT +3. The time now is 01:22 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org