Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Steven D'Aprano
Tom Lin wrote: > But one precondition is not to use int(string, base). How would you > implement the conversion? It's not hard. You have two choices: each character of the string represents a bit, and should be either a "0" or a "1" (anything else is an error). In which case its numeric value is

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Tom Lin
于 2011-1-18 21:08, Christian Witts 写道: > On 18/01/2011 14:45, Tom Lin wrote: >> Hi guys, >> >> Please help me with this: >> Convert an IP address from binary string to decimal format.There are >> some preconditions: >> 1.IP address is in the form of '10010001100'.32 bits with no dot. >> 2.i

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Steven D'Aprano
Tom Lin wrote: > Hi guys, > > Please help me with this: We don't do homework. We'll give you some hints but not do the work. > Convert an IP address from binary string to decimal format.There are > some preconditions: > 1.IP address is in the form of '10010001100'.32 bits with no dot. >

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread bob gailer
On 1/18/2011 8:08 AM, Christian Witts wrote: On 18/01/2011 14:45, Tom Lin wrote: Hi guys, Please help me with this: Convert an IP address from binary string to decimal format.There are some preconditions: 1.IP address is in the form of '10010001100'.32 bits with no dot. 2.int(string, ba

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Christian Witts
On 18/01/2011 14:45, Tom Lin wrote: > Hi guys, > > Please help me with this: > Convert an IP address from binary string to decimal format.There are > some preconditions: > 1.IP address is in the form of '10010001100'.32 bits with no dot. > 2.int(string, base) is not allowed, You have to imp

[Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Tom Lin
Hi guys, Please help me with this: Convert an IP address from binary string to decimal format.There are some preconditions: 1.IP address is in the form of '10010001100'.32 bits with no dot. 2.int(string, base) is not allowed, You have to implement the conversion . 3.Performance should be c