mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2014-02-14, 04:43   #12
daxmick
 
daxmick's Avatar
 
Feb 2014

22×3×7 Posts
Default

Quote:
Originally Posted by WraithX View Post
A couple of things to check would be, print out the value of both NumberToTest and Prime (perhaps both the value and the resource id) to see if one or both are having problems. Also, an example on the php website shows an extra check for empty rows before using the result of fetchArray. You can see that here:
http://www.php.net/manual/en/sqlite3...fetcharray.php

Maybe your query is returning empty rows. To that point, maybe there are empty rows in your db? Try to look in your db to see if this may be the case. Or, maybe you should use fetchArray(SQLITE3_ASSOC) to guarantee you can call into the resultant array by string name 'thenumber'.

Also, can your gmp_cmp use the integer 0 as a value? Or should you be comparing against the string '0'? And, maybe the same thing for your gmp_add. Can you use the integer 1 as a value, or should that be the string value '1'?

I haven't programmed too much in PHP, but hopefully this will give you some things to look into to see if you can narrow down where the problem is coming from.
Thanks WraithX! I'll look into this more and see. I'm pretty sure I don't have any empty entries in my database since I set "thenumber" to be UNIQUE and NOT NULL but it is worth double checking.

Also, I was mistaken when I said it selects a resource id randomly. It assigns them incrementally. So it appears that eventually I run out of resource ids. I guess I need to figure out how to reset the resource id allocation back to "#1".

I do like your suggestion on the gmp_cmp! Good catch!
daxmick is offline   Reply With Quote
Old 2014-02-14, 05:09   #13
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

3×17×131 Posts
Default

So is any of the following wrong?
  • GMP produces resources for PHP to reference.
  • The numbers held in those resources could be any size or value (32-bits, 64-bits, 2000-bits, whatever).
  • Resource numbers produced by GMP are just integers (a sequential number used to reference the next resource).
  • Once you have called GMP 2^31 times (for anything) the resource reference number is also going to be 2^31
  • PHP reads in the resource number and blows-up when it reads 2^31 because of some 32-bit limitation wrapping around.
Assuming all of the above if correct then There are two ways to fix it:
  1. Run 64-bit PHP.
  2. Occasionally restart GMP so that the resource numbering is reset back to 0.
retina is online now   Reply With Quote
Old 2014-02-14, 06:14   #14
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

150318 Posts
Default

Quote:
Originally Posted by retina View Post
  • PHP reads in the resource number and blows-up when it reads 2^31 because of some 32-bit limitation wrapping around.
Hmm, a bad assumption on my part because it could also be a problem in GMP producing an invalid resource number when it reaches 2^31. Anyhow, whatever the reason for it the second solution would solve it: restart GMP after 2giga-calls to reset the numbering back to zero.
retina is online now   Reply With Quote
Old 2014-02-14, 07:11   #15
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
"name field"
Jun 2011
Thailand

2·32·571 Posts
Default

For the OP: (original poster)

I have the perfect link that will solve your problem.
(I am with chalsall here, he might be rude, but he is right - you are very fast in pointing bugs in tools people use for ages, and you have no idea what you are talking about, I am not talking about 'collecting all primes' stuff - I let RDS to deal with it , but about messing types, having no understandings how gmp nor php works, etc - we all have better things to do than teaching manners, additionally, we are missing some manners ourselves, so we can't teach things we don't know...).

Last fiddled with by LaurV on 2014-02-14 at 07:34
LaurV is online now   Reply With Quote
Old 2014-02-14, 11:57   #16
daxmick
 
daxmick's Avatar
 
Feb 2014

22×3×7 Posts
Default

Quote:
Originally Posted by LaurV View Post
For the OP: (original poster)

I have the perfect link that will solve your problem.
(I am with chalsall here, he might be rude, but he is right - you are very fast in pointing bugs in tools people use for ages, and you have no idea what you are talking about, I am not talking about 'collecting all primes' stuff - I let RDS to deal with it , but about messing types, having no understandings how gmp nor php works, etc - we all have better things to do than teaching manners, additionally, we are missing some manners ourselves, so we can't teach things we don't know...).
Interesting. First, this isn't a homework lesson as I've been out of school for a few decades now. :-)

My apologies to all. I thought this was a forum to ask for help with, what I think, is an interesting issue. I find it odd how GMP resource allocation is doing what it is in this particular program as it doesn't behave this way in other programs and thought you all might find it of interest too. (Or find an obvious issue with my code.)

So, with that, I wish to thank those who tried to help. I really have tried to figure out what is the problem with what should be a rather easy program and some of you have at least tried to assist productively. For others, well, I'm sorry my quest for a solution has rubbed you the wrong way so terribly. Good bye.
daxmick is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rho code Happy5214 YAFU 3 2015-11-01 21:54
Code Help Andrew Programming 12 2013-02-16 20:53
New Code JohnFullspeed Programming 20 2011-09-04 04:28
Code Primeinator Software 20 2009-06-11 22:22
A little help with VBS code IronBits No Prime Left Behind 6 2008-11-12 14:23

All times are UTC. The time now is 06:33.


Wed Feb 1 06:33:22 UTC 2023 up 167 days, 4:01, 0 users, load averages: 1.47, 1.15, 1.04

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔