Search found 2879 matches

by Richard
Dec 20, 2018 5:39
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

The multiply of 1 million digit numbers in ASCII strings is really never going to be used because humans will never read all those digits. The time taken to code in ASM for a little used program is therefore wasted. Some internal binary format that avoids MOD will be faster because it does not need ...
by Richard
Dec 18, 2018 20:51
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

When you do an integer division (a DIV b) you throw away the remainder which is (a MOD b).
It takes the same time to keep (a DIV b) as it does to keep the remainder (a MOD b).
So you are doing an unnecessary multiply and a subtract.
by Richard
Dec 18, 2018 4:18
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

@srvaldez. Let me know what happens if you replace Uinteger with Ulong throughout the pointer declaration and cast code. Also replace Uinteger in about line 135 with Dim as Ulong carry Try this... '======================================================================= Declare Sub random_digits( Byr...
by Richard
Dec 18, 2018 3:43
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

It was written between 2010 and 2013, before FB X64 was common. I run it on Win7 with 32 bit FB ver 1.04.0. I compile with options -exx -w pedantic so I always have bounds checking and seg error testing on. I do not use MacOS x64 so I really cannot help with that problem. My condolences for your han...
by Richard
Dec 18, 2018 1:57
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

@dodicat, as I showed, base 1e9 will be faster than base 1e7. Calculated from the number of partial products; 7^2=49, 9^2=81, the expected time taken will be 49/81 = 60.5% For 1 million digits my old base 1e9 multiplier code runs in 263 sec on my old system, compared to Albert's base 1e7 which runs ...
by Richard
Dec 15, 2018 22:01
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

Can you guys see , where i'm screwing up?? Yes, it is clear and obvious. You are failing to document your brilliant code, so we cannot possibly know how you are trying to do it. As it is, your code looks like it comes from a post-modernist phrase generator. You should describe your plan or algorith...
by Richard
Dec 15, 2018 4:06
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

I do not understand what you mean by an “18 digit pointer”.
Is it pointing to a 64 bit integer that contains a number between 0 and (1e18)-1, or is it a byte pointer into a string of ascii which is the same as a string index?
by Richard
Dec 15, 2018 2:00
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

@Albert. I cannot see how using byte pointers can speed things up. It will be slower by 1/(4x4) = 1/16th as fast as pointers to 32 bit integer multiplies. The speed limit is determined by the maximum size of the partial product that can be produced. At the moment the widest accurate multiply availab...
by Richard
Dec 15, 2018 1:00
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

@dodicat. All things are relative when comparing algorithms. That 22.6 second code takes 360 seconds on my old system, so you are getting a combined total of 16 times speed advantage from your CPU, compiler, optimiser and runtime priority. How are you doing the compile? I suspect you are emitting C ...
by Richard
Dec 14, 2018 4:13
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

You already have the million mult much less than one minute (The forum fastest). Given two strings, each of one million random ascii digits, 0 to 9 without signs or decimal points, I think it would be hard to multiply them to get the two million character product string in less than a minute. Does ...
by Richard
Dec 13, 2018 3:36
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

Albert, it seems to me that, as you are repeatedly halving, examining a bit and conditionally adding, you are actually really doing long multiplication. Only, like making a ship in a bottle, you are doing it in the most difficult and obtuse way that could still possibly work. I find making ships in ...
by Richard
Dec 11, 2018 21:15
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

@Albert. Even though we would all like to be clairvoyant mind readers, we are human. Without meaningful documentation you are alone and we cannot help. If you clearly described your algorithm, a good mathematician could show how fast it would be, or if it was impossible, long before you got bogged d...
by Richard
Nov 02, 2018 5:19
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

If you keep everything as integers you can do;
Dim as Integer n1, n2, sum, fract, avg
sum = n1 + n2
fract = sum And 1 ' test if odd, fract is 1 if half
avg = sum shr 1 ' which divides by two
by Richard
Nov 02, 2018 1:06
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

@Albert.
You have no choice but to convert the number to decimal using the st = Str( dp ) function, then parse the string.
You need to better specify the input range and data format to get a better answer.
by Richard
Oct 12, 2018 0:25
Forum: General
Topic: Squares
Replies: 6384
Views: 366082

Re: Squares

I was thinking, if you convert to binary then you can step by 32 bits..without a sub-carry. There are many possibilities. Go ahead and see what you can do. The resized array can be referenced by pointers as 8, 16 or 32 bit unsigned integers. Because the array gets an extra zero most significant ele...

Go to advanced search