On Saturday, 14 February 2015 at 08:01:27 UTC, Ola Fosheim
Grøstad wrote:
I think the naming depends on use context, so it is reasonable
to
land on different names in different domains. Maybe the standard
notation should be ffs(x):
Oops, I meant fls(x)... I just woke up :-P. It is a bad name
a
On Friday, 13 February 2015 at 22:39:10 UTC, bearophile wrote:
H. S. Teoh:
So it could be called ilog2?
Perhaps floorIlog2? Isn't ilog2 a different function?
Bye,
bearophile
I think the naming depends on use context, so it is reasonable to
land on different names in different domains. Mayb
H. S. Teoh:
So it could be called ilog2?
Perhaps floorIlog2? Isn't ilog2 a different function?
Bye,
bearophile
On Fri, Feb 13, 2015 at 07:54:32PM +, via Digitalmars-d-learn wrote:
> On Friday, 13 February 2015 at 15:14:44 UTC, H. S. Teoh wrote:
> >Isn't it essentially floor(log_2(a)), mathematically speaking? Maybe
> >that could be the basis of a better name?
>
> integer log2:
> https://graphics.stanfo
On Friday, 13 February 2015 at 15:14:44 UTC, H. S. Teoh wrote:
Isn't it essentially floor(log_2(a)), mathematically speaking?
Maybe
that could be the basis of a better name?
integer log2:
https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogFloat
H. S. Teoh:
Maybe that could be the basis of a better name?
Right.
Bye,
bearophile
On Fri, Feb 13, 2015 at 12:28:23PM +, bearophile via Digitalmars-d-learn
wrote:
> Dominikus Dittes Scherkl:
>
> >I would recommend to use something like this:
> >
> >/// returns the number of the highest set bit +1 in the given value
> >/// or 0 if no bit is set
> >size_t bitlen(T)(const(T) a
Dominikus Dittes Scherkl:
I would recommend to use something like this:
/// returns the number of the highest set bit +1 in the given
value or 0 if no bit is set
size_t bitlen(T)(const(T) a) pure @safe @nogc nothrow
if(isUnsigned!T)
{
static if(T.sizeof <= size_t.sizeof) // doesn't work f
On Monday, 19 January 2015 at 20:54:50 UTC, Steven Schveighoffer
wrote:
Cool. I would point out that the commented code suggests you
should be handling the 0 case, but you are not (when T.min ==
T.max)
Should I do a Phobos PR for this? If so where should I put it?
On Monday, 19 January 2015 at 21:23:47 UTC, Nordlöw wrote:
On Monday, 19 January 2015 at 20:54:50 UTC, Steven
Schveighoffer wrote:
Cool. I would point out that the commented code suggests you
should be handling the 0 case, but you are not (when T.min ==
T.max)
I believe that should trigger a
On Monday, 19 January 2015 at 20:54:50 UTC, Steven Schveighoffer
wrote:
Cool. I would point out that the commented code suggests you
should be handling the 0 case, but you are not (when T.min ==
T.max)
I believe that should trigger a failing static assert with a good
error message as it doesn
On 1/19/15 3:46 PM, "Nordlöw" wrote:
On Monday, 19 January 2015 at 13:30:47 UTC, Steven Schveighoffer wrote:
http://dlang.org/phobos/core_bitop.html#.bsr
It's actually an intrinsic, reduces to an instruction. Mind the
requirements for 0.
This works for me
https://github.com/nordlow/justd/blo
On Monday, 19 January 2015 at 13:30:47 UTC, Steven Schveighoffer
wrote:
http://dlang.org/phobos/core_bitop.html#.bsr
It's actually an intrinsic, reduces to an instruction. Mind the
requirements for 0.
This works for me
https://github.com/nordlow/justd/blob/master/traits_ex.d#L406
:)
On Monday, January 19, 2015 13:37:12 Steven Schveighoffer via
Digitalmars-d-learn wrote:
> On 1/19/15 12:35 PM, Jonathan M Davis via Digitalmars-d-learn wrote:
> > On Monday, January 19, 2015 08:30:47 Steven Schveighoffer via
> > Digitalmars-d-learn wrote:
> >> http://dlang.org/phobos/core_bitop.
On 1/19/15 10:49 AM, "Per =?UTF-8?B?Tm9yZGzDtnci?=
" wrote:
On Monday, 19 January 2015 at 13:30:47 UTC, Steven Schveighoffer wrote:
http://dlang.org/phobos/core_bitop.html#.bsr
It's actually an intrinsic, reduces to an instruction. Mind the
requirements for 0.
Nice. Is this intrinsic support
On 1/19/15 12:35 PM, Jonathan M Davis via Digitalmars-d-learn wrote:
On Monday, January 19, 2015 08:30:47 Steven Schveighoffer via
Digitalmars-d-learn wrote:
http://dlang.org/phobos/core_bitop.html#.bsr
It's actually an intrinsic, reduces to an instruction. Mind the
requirements for 0.
Sadly
On Monday, January 19, 2015 08:30:47 Steven Schveighoffer via
Digitalmars-d-learn wrote:
> http://dlang.org/phobos/core_bitop.html#.bsr
>
> It's actually an intrinsic, reduces to an instruction. Mind the
> requirements for 0.
Sadly, I don't think that it have occurred to me from just reading the
On Monday, 19 January 2015 at 13:30:47 UTC, Steven Schveighoffer
wrote:
http://dlang.org/phobos/core_bitop.html#.bsr
It's actually an intrinsic, reduces to an instruction. Mind the
requirements for 0.
-Steve
Nice. Is this intrinsic supported for all DMD/GCD/LDC supported
platforms or do we
On 1/19/15 7:04 AM, "Per =?UTF-8?B?Tm9yZGzDtnci?=
" wrote:
As a follow-up to
http://forum.dlang.org/thread/fdfwrdtjcawprvvko...@forum.dlang.org#post-qxudiyoygnvvbovhjfgt:40forum.dlang.org
I'm looking for a function that figures out the number of bits that are
needed to represent a zero-based i
On Mon, 19 Jan 2015 12:04:38 +
via Digitalmars-d-learn wrote:
> As a follow-up to
>
> http://forum.dlang.org/thread/fdfwrdtjcawprvvko...@forum.dlang.org#post-qxudiyoygnvvbovhjfgt:40forum.dlang.org
>
> I'm looking for a function that figures out the number of bits
> that are needed to repre
Per Nordlöw:
I'm looking for a function that figures out the number of bits
that are needed to represent a zero-based integer:
//
http://stackoverflow.com/questions/3272424/compute-fast-log-base-2-ceiling
uint ceilLog2(ulong x) pure nothrow @safe @nogc
in {
assert(x > 0);
} body {
On Monday, January 19, 2015 12:04:38 via Digitalmars-d-learn wrote:
> As a follow-up to
>
> http://forum.dlang.org/thread/fdfwrdtjcawprvvko...@forum.dlang.org#post-qxudiyoygnvvbovhjfgt:40forum.dlang.org
>
> I'm looking for a function that figures out the number of bits
> that are needed to represen
As a follow-up to
http://forum.dlang.org/thread/fdfwrdtjcawprvvko...@forum.dlang.org#post-qxudiyoygnvvbovhjfgt:40forum.dlang.org
I'm looking for a function that figures out the number of bits
that are needed to represent a zero-based integer:
value-set => bits
=
0,1 => 1 (*)
0
23 matches
Mail list logo