Re: Formatted Integer With Specified Number Of Digits

Michael Torrie via Python-list <[email protected]>
Newsgroups gmane.comp.python.general
Message-ID <[email protected]>
On 10/24/25 4:38 AM, Alan Bawden wrote:
> Paul Rubin <[email protected]> writes:
> 
>    Lawrence D’Oliveiro <[email protected]> writes:
>    >     >>> "%#0.3x" % 2
>    >     '0x002'
> 
>    f'0x{2:03x}
> 
> Won't work for negative numbers.

That's true.  For negative numbers the padding would have to be Fs
instead of 0s.

-- 
https://mail.python.org/mailman3//lists/python-list.python.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.