Ask Your Question

Is the `hex(31)` conversion deprecated or not?

asked 2020-06-14 00:43:41 +0200

dsejas gravatar image

Hello, Sage Community!

A few months ago, when compiling Sage code to convert the decimal 31 to hexadecimal notation, I got a deprecation warning message telling me not to use hex(31), but 31.hex(). That was with SageMath 8.x (possibly 8.8 or 8.9; I don't remember exactly).

However, right now (version 9.1), when I run the command hex(31), it returns ``0x1f (the decimal representation of decimal 31), without any deprecation warning.

As the title says: Is the hex(31) conversion deprecated or not?

Other problem: hex(31) return 0x1f, while 31.hex() returns 1f

Thanks in advance for your answers!


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-06-14 22:05:28 +0200

tmonteil gravatar image

It is a known issue, but no consensus was found about fixing it, see!msg...

edit flag offensive delete link more


Hello, @tmonteil! Following that discussion, if I define

def hello():

I do get a deprecation warning about using 0o12 instead. However, if I define

def hello():

I don't get any warning, nor if I do

def hello():

However, I get an inconsistent output: the former gives 0x1f, while the latter gives just 1f.

dsejas gravatar imagedsejas ( 2020-06-22 18:17:26 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-06-14 00:43:41 +0200

Seen: 1,189 times

Last updated: Jun 14 '20