Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to convert he boolean values into integers

Reply
Thread Tools

How to convert he boolean values into integers

 
 
krishna
Guest
Posts: n/a
 
      06-25-2009
Hi Guys,

I need to convert 1010100110 boolean value to some think like 2345, if
its possible then post me your comment on this

Advanced thanks for all

Narayana perumal.G
 
Reply With Quote
 
 
 
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      06-25-2009
krishna wrote:
> I need to convert 1010100110 boolean value to some think like 2345, if
> its possible then post me your comment on this


Yes, sure. You can simply sum up the digit values and then format them as
decimal number. You can also just look up the number:

def decode_binary(input):
for i in range(2**len(input)):
if bin(i)==input:
return str(i)

I Hope I was able to help you with your homework! ;^)

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

 
Reply With Quote
 
 
 
 
samwyse
Guest
Posts: n/a
 
      06-25-2009
>>> int('1010100110', 2)
678

On Jun 25, 7:06*am, krishna <(E-Mail Removed)> wrote:
> Hi Guys,
>
> I need to convert 1010100110 boolean value to some think like 2345, if
> its possible then post me your comment on this
>
> Advanced thanks for all
>
> Narayana perumal.G


 
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: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Subtle difference between boolean value and boolean comparison? Metre Meter Javascript 7 08-06-2010 08:40 PM
difference between 'boolean' and 'java.lang.Boolean' J Leonard Java 4 01-19-2008 02:56 AM
Numarray - Using Integers Efficiently for Boolean Values andrewfelch@gmail.com Python 0 02-16-2006 06:19 PM
Consume RPC/Encoded webservice from ASP.NET double,integers,boolean problem Pokkie ASP .Net Web Services 1 05-06-2005 04:54 PM



Advertisments