Re: bigint and pow

2022-10-02 Thread rassoc via Digitalmars-d-learn
On 10/2/22 09:24, Fausto via Digitalmars-d-learn wrote: Thanks a lot. I am to used to C and, more important, I didn't think to look for also another operator for the power function :) Oh, and I forgot to mention that this is doing what you probably asked for originally: ```d import std; imp

Re: bigint and pow

2022-10-02 Thread rassoc via Digitalmars-d-learn
On 10/2/22 09:24, Fausto via Digitalmars-d-learn wrote: Thanks a lot. I am to used to C and, more important, I didn't think to look for also another operator for the power function :) D does have pow and many other useful math functions [1], it's just not defined for BitInts. Oh, and speakin

Re: bigint and pow

2022-10-02 Thread Fausto via Digitalmars-d-learn
On Sunday, 2 October 2022 at 02:02:37 UTC, rassoc wrote: On 10/2/22 00:04, Fausto via Digitalmars-d-learn wrote: Hello, I am trying to use pow with an integer argument, but I cannot have a bigint result, for example, ```pow(10,72)```. Do I have to write my pow function or is there a native so

Re: bigint and pow

2022-10-01 Thread rassoc via Digitalmars-d-learn
On 10/2/22 00:04, Fausto via Digitalmars-d-learn wrote: Hello, I am trying to use pow with an integer argument, but I cannot have a bigint result, for example, ```pow(10,72)```. Do I have to write my pow function or is there a native solution? thanks, Fausto In contrast to certain scripting

bigint and pow

2022-10-01 Thread Fausto via Digitalmars-d-learn
Hello, I am trying to use pow with an integer argument, but I cannot have a bigint result, for example, ```pow(10,72)```. Do I have to write my pow function or is there a native solution? thanks, Fausto

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 17:28:50 UTC, Dennis Ritchie wrote: 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 typ

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 = 18_446_724_073_70

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 = 18_446_724_073_70

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 = 18_446_724_073_70

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 >>>

2014-12-19 Thread Andre via Digitalmars-d-learn
Great! Thanks a lot. Kind regards André On Friday, 19 December 2014 at 08:47:50 UTC, bearophile wrote: Andre: Do you have any idea how to translate the coding correctly? Try: i += long(buffer[3]) << 24 >>> 0; But I also suggest to add parentheses, to make the code less unreadable for hum

Re: BigInt and >>>

2014-12-19 Thread bearophile via Digitalmars-d-learn
Andre: Do you have any idea how to translate the coding correctly? Try: i += long(buffer[3]) << 24 >>> 0; But I also suggest to add parentheses, to make the code less unreadable for humans. Bye, bearophile

BigInt and >>>

2014-12-18 Thread Andre via Digitalmars-d-learn
Hi, I try to translate following javascript coding to D: i = buffer[2] << 16; i |= buffer[1] << 8; i |= buffer[0]; i += buffer[3] << 24 >>> 0; Buffer is: [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 111] Expected result for i is: 4294967295 But in D the last st

Re: Cantor tuple function, BigInt, and integer overflow

2012-12-20 Thread H. S. Teoh
On Thu, Dec 20, 2012 at 07:46:39PM +0100, Joseph Rushton Wakeling wrote: > Hello all, > > I've been playing around trying to implement the Cantor tuple function > (see attached code), which is essentially a way to map a sequence x1, > x2, ..., xN of non-negative integers to a single unique number.

Cantor tuple function, BigInt, and integer overflow

2012-12-20 Thread Joseph Rushton Wakeling
Hello all, I've been playing around trying to implement the Cantor tuple function (see attached code), which is essentially a way to map a sequence x1, x2, ..., xN of non-negative integers to a single unique number. See: https://en.wikipedia.org/wiki/Pairing_function#Cantor_pairing_function