fork download
  1. import std.stdio;
  2.  
  3. void main() {
  4. auto a = new long[4];
  5. foreach (i; 0 .. 4) {
  6. a[i] = 1 << i;
  7. }
  8. writeln(a);
  9.  
  10. auto b = new long[4];
  11. foreach (i; 0 .. 4) {
  12. b[i] = (((1 >> i) & 1) ? -1 : +1) * a[i];
  13. }
  14. writeln(b);
  15. }
  16.  
Success #stdin #stdout 0s 4404KB
stdin
Standard input is empty
stdout
[1, 2, 4, 8]
[4294967295, 2, 4, 8]