Hi all
in windows programming there is a
function named "showbits" which displays
a particular value into its binary form...
Is there as such function available for linux also?
plz comment
thanks & regards
Sanjeev
Hi all
in windows programming there is a
function named "showbits" which displays
a particular value into its binary form...
Is there as such function available for linux also?
plz comment
thanks & regards
Sanjeev
No, but rolling your own is not too difficult.
http://www.daniweb.com/code/snippet148.html
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Not that I know of. However, it's not too difficult to come up with a string representation of the bits using some simple bitwise operations. If there is no standard alternative, I'd suggest writing a function for it.
EDIT: Sorry, wrote this a while ago, just forgot to submit it. :/
Sent from my iPadŽ
If you search this board for "number binary representation" or something similar, you'll find lots of hits. It comes up every once in a while.
Multiple tabs/windows, eh?EDIT: Sorry, wrote this a while ago, just forgot to submit it. :/
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Code:char *table[] = { "0000000000000000", "0000000000000001", "0000000000000010", "0000000000000011", // etc etc }; printf("%s", table[value]);
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
When I was doing bit manip/reading in Java... I converted each byte to a array of bools... I made a class to handle all the stuff for me but essentually, I had something to convert an array of bools to any type and I had a to string funtion that I used for printing it... it is relatively easy to just shift and check to see if it ANDs with 1 to make the array. I am sure it would be pretty easy to implement it in other languages... (I think I have a Perl version laying around too...)
thanks Brian....
Originally Posted by sanjeev_ddas