Re: How to convert a number to hex number?

2005-11-09 Thread Ron Adam
Bengt Richter wrote: On Wed, 09 Nov 2005 00:42:45 GMT, Ron Adam [EMAIL PROTECTED] wrote: Bengt Richter wrote: On 08 Nov 2005 08:07:34 -0800, Paul Rubin http://[EMAIL PROTECTED] wrote: dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of

How to convert a number to hex number?

2005-11-08 Thread Hako
I try this command: import string string.atoi('78',16) 120 this is 120 not 4E. Someone can tell me how to convert a decimal number to hex number? Can print A, B, C,DEF. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert a number to hex number?

2005-11-08 Thread Daniel Evers
Hi! Try hex: hex(120) '0x78' Consider converting string - int using the int()-function: print int.__doc__ int(x[, base]) - integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of

Re: How to convert a number to hex number?

2005-11-08 Thread dcrespo
And if you want only the hex number, try: hex(255)[2:] 'ff' -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert a number to hex number?

2005-11-08 Thread Paul Rubin
dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex() output can vary. Try hex(33**33). -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert a number to hex number?

2005-11-08 Thread Steve Holden
Paul Rubin wrote: dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex() output can vary. Try hex(33**33). ? You're usually smarter than this, or am I missing some joke? hex(33*33) '0x441' hex(33*33)[2:] '441' 33*33 1089 %x %

Re: How to convert a number to hex number?

2005-11-08 Thread Paul Rubin
Steve Holden [EMAIL PROTECTED] writes: Try hex(33**33). You're usually smarter than this, or am I missing some joke? hex(33*33) '0x441' You used only one * (multiplication), I used two *'s (exponentiation). hex(33**33) '0x5857366DCE0162CB5DDCD1BF0FC7C03A6438304421L' --

Re: How to convert a number to hex number?

2005-11-08 Thread Steve Holden
Paul Rubin wrote: Steve Holden [EMAIL PROTECTED] writes: Try hex(33**33). You're usually smarter than this, or am I missing some joke? hex(33*33) '0x441' You used only one * (multiplication), I used two *'s (exponentiation). hex(33**33)

Re: How to convert a number to hex number?

2005-11-08 Thread Bengt Richter
On 08 Nov 2005 08:07:34 -0800, Paul Rubin http://[EMAIL PROTECTED] wrote: dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex() output can vary. Try hex(33**33). Not to mention ([EMAIL PROTECTED] deleted ;-) hex(-255)[2:] 'xff' hex(-255)

Re: How to convert a number to hex number?

2005-11-08 Thread Ron Adam
Bengt Richter wrote: On 08 Nov 2005 08:07:34 -0800, Paul Rubin http://[EMAIL PROTECTED] wrote: dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex() output can vary. Try hex(33**33). Not to mention ([EMAIL PROTECTED] deleted ;-)

Re: How to convert a number to hex number?

2005-11-08 Thread Bengt Richter
On Wed, 09 Nov 2005 00:42:45 GMT, Ron Adam [EMAIL PROTECTED] wrote: Bengt Richter wrote: On 08 Nov 2005 08:07:34 -0800, Paul Rubin http://[EMAIL PROTECTED] wrote: dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex() output can vary. Try