Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Convert integer to fixed length binary string

Reply
Thread Tools

Re: Convert integer to fixed length binary string

 
 
Mark Dickinson
Guest
Posts: n/a
 
      06-11-2009
On Jun 11, 10:29*am, casebash <walkr...@gmail.com> wrote:
> Sorry, I didn't quite make it clear. The issue isn't about limiting
> the length (as I won't be using integers bigger than this). The
> problem is that sometimes the output is shorter.


Is this what you're looking for?

Python 2.6.2 (r262:71600, Jun 8 2009, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> '{0:032b}'.format(12345)

'00000000000000000011000000111001'

Mark
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: iostream >> string, but fixed length string - how? cpp4ever C++ 2 05-04-2010 10:50 PM
Re: iostream >> string, but fixed length string - how? Victor Bazarov C++ 2 05-03-2010 07:16 AM
Re: Convert integer to fixed length binary string Ulrich Eckhardt Python 1 06-12-2009 02:03 AM
String exceeding length - Getting absolute string length james.w.appleby@gmail.com Java 5 01-11-2007 12:07 AM
left(string, length) or right(string, length)? Sam ASP .Net 3 02-17-2005 12:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57