On Sunday, 25 March 2018 at 11:32:56 UTC, Alex wrote:
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?
Via bit checking I would end with this: ´´´ void assign(BitArray ba, size_t val) //@nogc { import std.algorithm : each; assert(ba.length == size_t.sizeof * CHAR_BIT); val.bitsSet.each!(b => ba.flip(b)); } ´´´