Challenge for you... - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Programs (https://staging.qb64phoenix.com/forumdisplay.php?fid=7) +---- Thread: Challenge for you... (/showthread.php?tid=1629) |
RE: Challenge for you... - Kernelpanic - 04-20-2023 @bplus - Written out, it matches Julia. Now if I knew how to force the "...e+XXXX" I could check that. But I couldn't find it that quickly. But it is definitely somewhere in the 1565 pages of the manual. RE: Challenge for you... - bplus - 04-20-2023 (04-20-2023, 09:13 PM)Kernelpanic Wrote: @bplus - Written out, it matches Julia. Now if I knew how to force the "...e+XXXX" I could check that. But I couldn't find it that quickly. But it is definitely somewhere in the 1565 pages of the manual. Say, can Julia do the rest of the formula with the powers and COS that Eric posted at the start and Jack has in QB64 for 6 primes? RE: Challenge for you... - Jack - 04-20-2023 even if you could handle big factorials for n = 100 --> 2^100 --> 1267650600228229401496703205376 it would take forever to complete Code: (Select All) For i = 1 To 1267650600228229401496703205376 RE: Challenge for you... - eoredson - 04-21-2023 @jack: Kudos on the first translation of the formula to BASIC. Note: This program returns prime 7 as 129 so the formula may be incorrect. Btw: Pi can be calculated as Atn(1)*4 Erik. RE: Challenge for you... - Jack - 04-21-2023 @eoredson the formula is correct, but 6 primes is the maximum that you are able to compute using double, with higher precision you could calculate more primes but it gets exponentially slow RE: Challenge for you... - eoredson - 04-21-2023 (04-21-2023, 12:50 AM)Jack Wrote: @eoredson So, could you extend your program to _unsigned _integer64 for higher values? I tried to change Double to _Float with no result.. RE: Challenge for you... - Jack - 04-21-2023 I don't think so, because of the cos function what you need is more floating point precision, but using _Float is not going to help because the trig functions are evaluated to double precision but even if cos was evaluated to full _Float precision it would help very little btw, did you watch the YouTube video? https://www.youtube.com/watch?v=j5s0h42GfvM RE: Challenge for you... - mnrvovrfc - 04-21-2023 (04-21-2023, 01:04 AM)eoredson Wrote:(04-21-2023, 12:50 AM)Jack Wrote: @eoredson 64-bit integer has at least 18 places of precision, maybe 19 and it depends on it being positive or negative. Each decimal place takes away from how large the number could be. However when computing primes there shouldn't be a need for fractions, or am I wrong? (That depends on how CURRENCY type was treated by M$ BASIC PDS v7.1 which was actually 32-bit integer.) https://qb64phoenix.com/qb64wiki/index.php/INTEGER64 The code that Jack showed a short time ago has a number 2^100 that will have to be represented by "string math". So not as much it will "take forever", but QB64(PE) doesn't have any numeric data type at the moment to represent such a value. LOL maybe that's why he said something about "bignum" ... RE: Challenge for you... - Jack - 04-21-2023 @mnrvovrfc go right ahead and complete the challenge and compute 100 primes using the formula, put your money where your mouth is, I seriously doubt that you would even compute 20 primes RE: Challenge for you... - eoredson - 04-21-2023 Actually, modifying your nthprime program slightly with Double extended to _Float it still returns the 7th prime as 129.. Code: (Select All) _Define A-Z As _FLOAT |