[ SOLVED ] Octo's Ghost Lib - Would like revising

they just take the bin version and compare each bit independently, this can be done with any slandered operation.

eg. a int of 2 in bin is 10 and a 3 is 11 so 2|3=11 beacuse in both bin place values there is at least one 1 whereas 2|2=10 because only the first bit has anything in it in ether case.

not quite:

or 4 & 4 = 0100 because it checks each bin placevalue and if the first AND the scond have a 1 then the result for that placevalue is a one otherwise it is 0

so 2|5 would be 101?

2 = 010; 5 = 101

so we compare each place value with our operator:

0 or 1 = 1
1 or 0 = 1
0 or 1 = 1

so 2|3=111

Ah, that makes sense. Reminds me vaguely of something we learned in Networking class. Binary operations are sorta like vertical problems:

2|3:

  10 (2)
| 11 (3)
----------
  11

So if either one in the column above is 1, then the resulting column is 1, then presumably both columns need to be 1 for an & operator to produce a 1:

  10 (2)
& 11 (3)
-----------
  10

So it checks each binary section and compares them INDIVIDUALLY? Ooooh, that makes a lot more sense!

so if 2|5=111, 2&5=…?

Yup, you do the operation on each bit independently; an or means if the place value being looked at in the first one is 1 or the second; and means and.

2=010; 5=101

0&1=0
1&0=0
0&1=0

so 2&5=000

Yup, you got it.

& will always return 0 if true, while | returns 1? What about 1&1? It would be 1, right? And 1|1=0 ?

I guess then these operators can chain more than two as well. But for varying amounts of bits, which way to the bits align? i.e. 2|5 would align at the leading or trailing bit?

 10   or   10 
101        101

Guess that’s somewhat answered from above answers XD And I suppose aligning at trailing would then make the 2 a 4, come to think of it.

the or is not exclusive, an Xor is a different operation. so 1|1=1 1|0=1 0|1=1 but 0|0=0

Right allined, like all bynary, adding 0’s to the left does not change the value, so add 0’s untill the legnths are equle.

I may have to go play with this in my redstone testing world. it’s easier to see how things are working that way…
Redstone now makes so much more sense… <3

Agreed XD Is there a simple way to output an integer’s raw binary to log it? And would non-numbers also translate to bits? Presumably a byte per character if so

I’m assuming that’s where ASCII chart comes into play?

Integer.toBinaryString()

2 Likes

I’d think. I’m under the impression that ASCII characters are comprised of 8-bits

came here to check code, left with a knowledge of how real-life redstone logic works.

1 Like

Just figure it out using the binary pattern, 1 2 4 8 16 32 64 128 256 …

take your number, say 133, for the bigest bin patern num it’s still smaller than, write a 1 and subtract it:

1 … 133- 128 = 5
then do it again, but if the next num in the bin pattern is too big write 0

10000 …

we find 4 so

100001 … 5 - 4 = 1 so

1000010 and we find one so

10000101 = 133

you can also use win calculator in programer mode (or advanced on XP and older) and change the raido buton from dec to bin with an number typed in, it will convert it

2 Likes

Let me show you a wireing diegram of a computer:
This is the circuit in a calculator, it adds, subtracts, and if you use it more than once in a row it can multiply and divide. This circuit, tessellated many times, on a pulse clock running at about 3.3Ghz is your CPU.

A is the input from the first number B from the second, ether 1 (on) or 0 (off); S is the output, there 1 or 0; C in is the carry switch (may carry a 1 from the last operation on the last place value); Cout is a carry out. (so you can carry the 1, just like long adding)

That moment when you’ve used diagrams like these to make redstone contraptions… xD

Well you can make this one with redstone, but a tick is 1/22 seconds so your CPU would only be 22Hz, but you could make a very good 1960’s computer that way. That would be cool.

Gosh darn it!!! Now you’ve got me thinking (that’s not a good thing, and so I try not to), I might just make a model of a 1960’s fully “digital” calculating auto-collator in redstone. Well there goes my weekend :wink: