Sujet : Re: format_binary
De : jon+usenet (at) *nospam* unequivocal.eu (Jon Ribbens)
Groupes : comp.lang.pythonDate : 24. Sep 2026, 07:57:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrn11b9if4.2kd.jon+usenet@raven.unequivocal.eu>
References : 1 2 3
User-Agent : slrn/1.0.3 (Linux)
On 2026-09-24, Lawrence D’Oliveiro <
ldo@nz.invalid> wrote:
On 23 Sep 2026 23:09:14 GMT, Stefan Ram wrote:
>
Like,
>
''.join( f'{i:08b}' for i in flag )
>
?
>
def format_binary(n : int) :
assert n >= 0
return \
"".join \
(
chr(ord("0") + (n & 1 << i != 0))
for i in range(math.floor(math.log(max(n, 1)) / math.log(2)), -1, -1)
)
#end format_binary
Well, that is the absolute worst of all possible ways to do it, yes.
Haut de la page
Les messages affichés proviennent d'usenet.
NewsPortal