Ask Your Question
0

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

asked 2020-06-13 17:43:41 -0600

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!

Related:https://ask.sagemath.org/question/519...

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2020-06-14 15:05:28 -0600

tmonteil gravatar image

It is a known issue, but no consensus was found about fixing it, see https://groups.google.com/forum/#!msg...

edit flag offensive delete link more

Comments

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

def hello():
    print(012)

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

def hello():
    print(hex(31))

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

def hello():
    print(31.hex())

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

dsejas gravatar imagedsejas ( 2020-06-22 11:17:26 -0600 )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

Stats

Asked: 2020-06-13 17:43:41 -0600

Seen: 94 times

Last updated: Jun 14