Ask Your Question

Revision history [back]

For a Sage integer (vs. python int), s.hex() gives just the hex digits, without the prefix '0x':

sage: s=123456                                                                  
sage: s.hex()                                                                   
'1e240'

hex(s) includes the prefix '0x':

sage: hex(s)                                                                    
'0x1e240'

You could strip off '0x' with hex(s)[2:], but s.hex() is simpler.

sage: hex(s)[2:]                                                                
'1e240'