BigInt and xor

2015-03-24 Thread Dennis Ritchie via Digitalmars-d-learn
Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n = 18_446_724_073_709_551_614U; bitArr[0] = format(%b, n).to!BigInt;

Re: BigInt and xor

2015-03-24 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 17:35:14 UTC, matovitch wrote: xor it with -1 instead of 1. (-1 is store as 0xfff..f with the classic modular arithmetic) Thanks.

Re: BigInt and xor

2015-03-24 Thread matovitch via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: BigInt and xor

2015-03-24 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 16:35:04 UTC, Ivan Kazmenko wrote: What exactly is not working? Everything works. I'm just a little forgotten properties of the operation xor. I just wanted to xor 1 each digit in the number of type BigInt, while I would like to store each number in the binary

Re: BigInt and xor

2015-03-24 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: BigInt and xor

2015-03-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: BigInt and xor

2015-03-24 Thread matovitch via Digitalmars-d-learn
of type BigInt, while I would like to store each number in the binary representation of the array BigInt. xor it with -1 instead of 1. (-1 is store as 0xfff..f with the classic modular arithmetic)