Jan 24, 2001 1 #1 stonecold Programmer Joined Jan 24, 2001 Messages 1 Location US I need to convert a single integer number to binary code and print the binary code out in c
Jan 24, 2001 #2 hnd Programmer Joined Apr 11, 2000 Messages 450 Location DE Perhaps there is a format converter string for binaries. For Hex it is %x hnd hasso55@yahoo.com Upvote 0 Downvote
Jan 24, 2001 1 #3 palbano Programmer Joined Oct 9, 1998 Messages 4,341 Location US If by 'binary code' you mean 5 = 0101 int number = 5; BigInteger bi = new BigInteger(new Integer(number).toString()); System.out.println( bi.toString(2)); Hope this helps -pete Upvote 0 Downvote
If by 'binary code' you mean 5 = 0101 int number = 5; BigInteger bi = new BigInteger(new Integer(number).toString()); System.out.println( bi.toString(2)); Hope this helps -pete
Jan 24, 2001 #4 palbano Programmer Joined Oct 9, 1998 Messages 4,341 Location US Ok, so now if you ever need to do this in Java you know how. So here is how to do it in C B-) char buf[255]; int myint = 5; _itoa(myint, buf, 2); /* buf now contains "101" */ Hope this helps -pete Upvote 0 Downvote
Ok, so now if you ever need to do this in Java you know how. So here is how to do it in C B-) char buf[255]; int myint = 5; _itoa(myint, buf, 2); /* buf now contains "101" */ Hope this helps -pete