dougal.s Posted October 22, 2004 Share Posted October 22, 2004 Hi guys. This is my final option, I have been trying for a few hours to do this and still haven't managed! Basically I have a 6 digit int that represents a six bit binary number, say 010000. I want to cast this to the equivalent byte value, in this case 16. Any help appreciated. Dougal. Link to comment Share on other sites More sharing options...
0 Mouton Posted October 22, 2004 Share Posted October 22, 2004 http://www.cs.princeton.edu/introcs/51data...erter.java.html Link to comment Share on other sites More sharing options...
0 dougal.s Posted October 22, 2004 Author Share Posted October 22, 2004 Not quite what i was looking for, but it has given me an idea. Thanks. Any other suggestions still welcome. Dougal. Link to comment Share on other sites More sharing options...
0 dougal.s Posted October 22, 2004 Author Share Posted October 22, 2004 Woo! Worked it out. Had my brackets in the wrong place. For all those interested...... answerAsByte = (byte)integerNumber; soooo simple! :D Dougal. Link to comment Share on other sites More sharing options...
0 tiagosilva29 Posted October 23, 2004 Share Posted October 23, 2004 I made something like that today @ college. /** * Integer * * @author Tiago F. Silva * @version IP 2004/2005 */ import java.util.Scanner; public class Integer { ? ? ? public static void main(String[] args) { ? ? ? Scanner kthx = new Scanner(System.in); ? ? ? System.out.println (Integer.valueOf(kthx.nextLine(), 2)); ? ? ? } } edit: ahah, you found it! g;)d for you ;) Link to comment Share on other sites More sharing options...
Question
dougal.s
Hi guys.
This is my final option, I have been trying for a few hours to do this and still haven't managed!
Basically I have a 6 digit int that represents a six bit binary number, say 010000. I want to cast this to the equivalent byte value, in this case 16.
Any help appreciated.
Dougal.
Link to comment
Share on other sites
4 answers to this question
Recommended Posts