Just another Perl shrine | |
PerlMonks |
Converting negative number to binary with specific widthby pjkang7 (Novice) |
on Nov 03, 2015 at 00:07 UTC ( [id://1146779]=perlquestion: print w/replies, xml ) | Need Help?? |
pjkang7 has asked for the wisdom of the Perl Monks concerning the following question: Hi, this is my first question post on PerlMonk. Just fyi, I have searched and tried for some good amount of time (>40min) and decided I could not find out what's wrong with my code. It's a simple one. Basically, I am trying to convert negative number into specific length (10) binary. And it's simply refusing to do that. Here's the code:
Another problem i had was if I am trying to convert 1024 into binary number:
Apparently, there's something wrong with my sprintf formating....and I can't figure it out. I have used substr to simply cut the string to my desired length as a way around it but I am still interested to find out what I did wrong... I turn to the wisdom of PerlMonks out there. Thank you.
Back to
Seekers of Perl Wisdom
|
|