Search found 2868 matches

by Richard
Dec 25, 2018 5:39
Forum: General
Topic: Squares
Replies: 6318
Views: 358195

Re: Squares

Merry Christmas to all the squares. @Albert. When an addition is performed, the XOR produces the sum of the bits while AND is used to generate the carry. That is why (a + b) - ( a and b ) shl 1 removes the carry and so leaves only the XOR function. It is not my formula, I have seen it around since t...
by Richard
Dec 24, 2018 6:54
Forum: General
Topic: Squares
Replies: 6318
Views: 358195

Re: Squares

Build an output string first using normal string functions and maybe the vb Format function. Then prefix that string with echo and Shell it out. To print you should first work out how to print on your particular operating system, then use Shell to issue that command to the system. You might consider...
by Richard
Dec 24, 2018 1:48
Forum: General
Topic: Squares
Replies: 6318
Views: 358195

Re: Squares

Sorry about that.

You can use carry subtraction to generate the Xor.

Code: Select all

' c = a Xor b
c = (a + b) - (a And b) shl 1
by Richard
Dec 24, 2018 1:11
Forum: General
Topic: Squares
Replies: 6318
Views: 358195

Re: Squares

This will bypass the graphics screen to print a string to the console in Windows.

Code: Select all

shell "echo "+ "string to console"
by Richard
Dec 20, 2018 5:39
Forum: General
Topic: Squares
Replies: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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: 6318
Views: 358195

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

Go to advanced search