On Feb 3, 1:19 am, Mark Wooding wrote:
> Yeah, I made some arbitrary choices about what to do with non-positive
> inputs. If you prefer other answers, use 'em. My ones work well with
> signed-magnitude representations where the sign is stored separately.
Not *that* arbitrary: they're the same
John Machin writes:
> 3 can be represented in 2 bits and at the same time -3 can be
> represented in 2 bits?? But 2 bits can support only 2 ** 2 == 4
> different possibilities, and -3 .. 3 is 7 different integers.
Yeah, I made some arbitrary choices about what to do with non-positive
inputs. If
On Jan 30, 11:03 pm, Jon Clements wrote:
> Hi Group,
>
> This has a certain amount of irony (as this is what I'm pretty much
> after):-
> Fromhttp://docs.python.org/dev/3.0/whatsnew/3.1.html:
> "The int() type gained a bit_length method that returns the number of
> bits necessary to represent its
On Feb 3, 6:50 am, Mark Wooding wrote:
> Jon Clements writes:
> > "The int() type gained a bit_length method that returns the number of
> > bits necessary to represent its argument in binary:"
>
> > Any tips on how to get this in 2.5.2 as that's the production version
> > I'm stuck with.
>
> def
On Jan 31, 7:03 am, Jon Clements wrote:
> Any tips on how to get this in 2.5.2 as that's the production version
> I'm stuck with.
It's a bit cheeky, but:
from decimal import _nbits as nbits
should also work in 2.5.2 (but not in 2.5.1)!
Mark
--
http://mail.python.org/mailman/listinfo/python-l
Jon Clements writes:
> "The int() type gained a bit_length method that returns the number of
> bits necessary to represent its argument in binary:"
>
> Any tips on how to get this in 2.5.2 as that's the production version
> I'm stuck with.
def nbits(x):
## Special cases.
if x == 0: return 0
On Jan 31, 7:29 am, John Machin wrote:
> On Jan 31, 6:03 pm, Jon Clements wrote:
>
> > Hi Group,
>
> > This has a certain amount of irony (as this is what I'm pretty much
> > after):-
> > Fromhttp://docs.python.org/dev/3.0/whatsnew/3.1.html:
> > "The int() type gained a bit_length method that ret
En Sat, 31 Jan 2009 05:03:27 -0200, Jon Clements
escribió:
This has a certain amount of irony (as this is what I'm pretty much
after):-
From http://docs.python.org/dev/3.0/whatsnew/3.1.html:
"The int() type gained a bit_length method that returns the number of
bits necessary to represent it
Jon Clements wrote:
... From http://docs.python.org/dev/3.0/whatsnew/3.1.html:
"The int() type gained a bit_length method that returns the number of
bits necessary to represent its argument in binary:"
Any tips on how to get this in 2.5.2 as that's the production version
I'm stuck with.
Well,
On Jan 31, 6:03 pm, Jon Clements wrote:
> Hi Group,
>
> This has a certain amount of irony (as this is what I'm pretty much
> after):-
> Fromhttp://docs.python.org/dev/3.0/whatsnew/3.1.html:
> "The int() type gained a bit_length method that returns the number of
> bits necessary to represent its a
10 matches
Mail list logo