Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-18 Thread Luis Mochan
... Just wanted to make sure you don't spend time chasing a dead-end with this parentheses bit: ... Ha! I should have known; not the first time it bites me. Thanks. Best regards, Luis -- W. Luis Mochán desde su inservible teléfono ___ Perldl

Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-17 Thread Derek Lamb
Hi Luis, You are correct, longlong(600851475143)%longlong(71) still fails. Sorry for not checking. I have a good idea on solving that… stand by. Just wanted to make sure you don't spend time chasing a dead-end with this parentheses bit: pdl p (600851475143)%(71) #WRONG and DIFFERENT from

[Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Luis Mochan
This is a nice solution, the answer is also correct. I have to spend some time trying to understand some PDL nuances there. I'm attaching a slightly commented versionin case it helps Not sure why you're having the errors due to 64-bit numbers though. :( Can someone else confirm the error. I

Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Chris Marshall
Hi Luis- I think you are tickling one of the known issues with proper longlong type support in PDL. Here is the original bug report (but I don't know if your problem comes about in exactly the same fashion). At any rate, it is definitely a wart on the longlong support.

Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Luis Mochan
Thanks Chris. Nevertheless, I believe it is a different error, as it manifest itself for very small values such as 10 and 5 in this example: pdl p 10%5 0 pdl p longlong(10)%longlong(5) 45219840 pdl p longlong(10)/longlong(5) 2 The quotient is correct, but the remainder isn't. Best

Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Zakariyya Mughal
On 2015-02-16 at 12:28:35 -0600, Luis Mochan wrote: I'm attaching a slightly commented versionin case it helps Very nice code! By the way, I noticed that you commented that you are using floor() from POSIX instead of from PDL. Why is that? I tried replacing the line my

Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Derek Lamb
Hi Luis, I have just pushed a commit to the main git master branch that fixes this problem on my machine. Please check it out if you're able and let the list know if you still experience this weird problem with modulo for longlong operands. Thanks for brining this to our attention. best,

Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Luis Mochan
Thanks Derek! Best regards, Luis On Mon, Feb 16, 2015 at 05:01:09PM -0700, Derek Lamb wrote: Hi Luis, I have just pushed a commit to the main git master branch that fixes this problem on my machine. Please check it out if you're able and let the list know if you still experience this

Re: [Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Luis Mochan
Dear Derek, I downloaded and compiled the git version and I made the following tests from the pdl-code directory mochan@em:~/Downloads/pdl-code$ ./pdl ... Loaded PDL v2.007 (supports bad values) #MY OLD PDL ... pdl p longlong(10)%longlong(5) #WRONG result 53870592 pdl q

[Perldl] Modulus fails (was Re: Project Euler and Perl)

2015-02-16 Thread Luis Mochan
I did some tests with the modulus operator, which seemed to act strangely for my proposed solution to the EUler problem: pdl p 10%5 0 pdl p long(10)%long(5) 0 pdl p longlong(10)%longlong(5) 36044800 So modulus fails when using the longlong data type. The 'Euler' problem involves a