issue 7006 - std.math.pow (integral, integral) crashes on negative exponents
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Mon Dec 16 17:11:22 UTC 2019
On Monday, 16 December 2019 at 17:07:42 UTC, Ola Fosheim Grøstad
wrote:
> On Monday, 16 December 2019 at 15:33:33 UTC, jmh530 wrote:
>> void main() {
>> auto x = iota(10).map!(a => a % 2 ? 1 : -1);
>> }
>
> xor or unrolling would be faster. I wouldn't trust a compiler
> on that one.
To explain, in case that was a bit brief (8 bit case):
-1 = 11111111
1 = 00000001
So all you have to do is xor with
~1 = 11111110
More information about the Digitalmars-d
mailing list