ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 22 Jun 2020 18:17:26 +0200Is the `hex(31)` conversion deprecated or not?https://ask.sagemath.org/question/51952/is-the-hex31-conversion-deprecated-or-not/ 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/51951/is-the-011-notation-for-octal-11-deprecated-or-not/
Sun, 14 Jun 2020 00:43:41 +0200https://ask.sagemath.org/question/51952/is-the-hex31-conversion-deprecated-or-not/Answer by tmonteil for <p>Hello, Sage Community!</p>
<p>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 <code>hex(31)</code>, but 31.hex(). That was with SageMath 8.x (possibly 8.8 or 8.9; I don't remember exactly).</p>
<p>However, right now (version 9.1), when I run the command <code>hex(31)</code>, it returns ``0x1f (the decimal representation of decimal 31), without any deprecation warning.</p>
<p>As the title says: Is the <code>hex(31)</code> conversion deprecated or not?</p>
<p><strong>Other problem:</strong> <code>hex(31)</code> return <code>0x1f</code>, while <code>31.hex()</code> returns <code>1f</code></p>
<p>Thanks in advance for your answers!</p>
<p><strong>Related:</strong><a href="https://ask.sagemath.org/question/51951/is-the-011-notation-for-octal-11-deprecated-or-not/">https://ask.sagemath.org/question/519...</a></p>
https://ask.sagemath.org/question/51952/is-the-hex31-conversion-deprecated-or-not/?answer=51986#post-id-51986It is a known issue, but no consensus was found about fixing it, see https://groups.google.com/forum/#!msg/sage-devel/Hm0SJiDVXHI/Ue5cWj7MDAAJ
Sun, 14 Jun 2020 22:05:28 +0200https://ask.sagemath.org/question/51952/is-the-hex31-conversion-deprecated-or-not/?answer=51986#post-id-51986Comment by dsejas for <p>It is a known issue, but no consensus was found about fixing it, see <a href="https://groups.google.com/forum/#!msg/sage-devel/Hm0SJiDVXHI/Ue5cWj7MDAAJ">https://groups.google.com/forum/#!msg...</a></p>
https://ask.sagemath.org/question/51952/is-the-hex31-conversion-deprecated-or-not/?comment=52147#post-id-52147Hello, @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`.Mon, 22 Jun 2020 18:17:26 +0200https://ask.sagemath.org/question/51952/is-the-hex31-conversion-deprecated-or-not/?comment=52147#post-id-52147