Jan 24, 2001 1 #1 stonecold Programmer Jan 24, 2001 1 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 Apr 11, 2000 450 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 Oct 9, 1998 4,341 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 Oct 9, 1998 4,341 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