Search found 2879 matches

by Richard
Jan 06, 2019 2:32
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@Albert. I have no idea what you think you are doing. But it seems you need to propagate carry by sweeping from right to left. 0001101110010000 = ans. 0001020302010000 = me. 0001020302010000 2 dec is 10 bin 0001020310010000 3 dec is 11 bin 0001021110010000 2 dec is 10 bin 0001101110010000 carry is n...
by Richard
Jan 05, 2019 7:20
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

I'm not sure I understand the question. A 1 million x 1 million digit multiply will have at most 1 million partial products to accumulate, so you will need at least 20 more bits in your accumulator register. 2^20 = 1 million, so I would accumulate in a 64 bit ULongInt passing carry to a 32 bit exten...
by Richard
Jan 05, 2019 2:07
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@Albert. Just like my diagonal multiply avoided multiple output references, to minimise the number of times Mod 1e9 and DIV 1e9 were called. You will find that for numbers with different lengths you will need a more complex control structure with two multiply kernels. Here is the anotated picture of...
by Richard
Jan 04, 2019 21:57
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@dodicat. Your computer does run differently. Maybe there is some advantage in 32 bits for string processing. n1 = 15745121398853196173 n2 = 16103048213999544446 15708977747966183436 0.1671305693962495 albert 15708977747966183436 0.12494262704422 dodicat 15708977747966183436 0.09886247960093897 rich...
by Richard
Jan 04, 2019 13:32
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@dodicat. Why spend all that time in the For Next loop. 'a ulongint generator Type Rand a As Ulongint b As Ulongint c As Ulongint d As Ulongint End Type Function ranulong( Byref x As rand ) As Ulongint Dim e As Ulongint = x.a - ( ( x.b Shl 7 ) Or ( x.b Shr ( 64 - 7 ) ) ) x.a = x.b xor ( ( x.c Shl 13...
by Richard
Jan 04, 2019 6:23
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@Albert. When you use strings to perform the AND operation on ULongInt data you should be doing the Bin() conversions every time inside your function. You should not be arbitrarily swapping the input numbers based on size, but should find and control the length of the strings inside your AND functio...
by Richard
Dec 31, 2018 3:55
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@Albert. My code is significantly slower than the built-in logic functions. There must be a problem with the way you are applying your speed testing code. I wrote the arithmetic logic functions to show that it is possible to “advance backwards” even faster, without using the MOD function. Speed has ...
by Richard
Dec 31, 2018 0:22
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@Albert. I quickly wrote and posted the arithmetic logic functions before driving all day. By the time I got back I'd thought about what I was doing and so could write them differently. I really can't think of any use for them, apart from filling time. I would have thought you would prohibit the use...
by Richard
Dec 29, 2018 21:00
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

' Bitwise Logic Functions, NOT, AND, OR, XOR, by arithmetic without using those logic functions '------------------------------------------------------- Function arith_NOT( Byval x As Ubyte ) As Ubyte Return 255 - x End Function '------------------------------------------------------- Function arit...
by Richard
Dec 29, 2018 9:40
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

Now to do numbers outside of powers of 2 You need to avoid the Mod function and start from the most primitive operators. They are NOT, AND and OR. You can then make XOR( a, b ) = ( a And Not(b) ) Or ( b And Not(a) ) from which you can do addition. Once you can ADD you can INCrement which makes it p...
by Richard
Dec 26, 2018 5:14
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

Re: Squares

@Albert. Why do you insist on doing the impossible backwards? The fundamental of logic is the Complement or NOT function. It can be done by one transistor and one input resistor. The fundamental two input AND and OR functions can be made simply using one diode for each input. By using a transistor t...
by Richard
Dec 25, 2018 5:39
Forum: General
Topic: Squares
Replies: 6384
Views: 365919

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: 6384
Views: 365919

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: 6384
Views: 365919

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: 6384
Views: 365919

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"

Go to advanced search