converting a number into bit array
Alex
sascha.orlov at gmail.com
Sun Mar 25 11:32:56 UTC 2018
Given this,
´´´
import std.bitmanip;
import core.stdc.limits;
void main()
{
BitArray ba;
ba.length = size_t.sizeof * CHAR_BIT; // enough length, known at
compile time
size_t arbitrary; // = random size_t, not known at compile time
// ba ???assign??? arbitrary;
assert(cast(size_t[])ba == [arbitrary]);
}
´´´
how to convert a number to a BitArray as fast as possible, given
that the BitArray is already allocated to the needed length?
Is bit checking the way to go, or is there a way to cast one to
the other somehow?
More information about the Digitalmars-d-learn
mailing list