eisental / RedstoneChips

A Bukkit plugin for digital redstone integrated circuits
eisental.github.com/RedstoneChips
GNU General Public License v3.0
22 stars 15 forks source link

Compare and Multiply issue @ 32bits.(re-posted in basiccircuits) #67

Closed RufiS closed 11 years ago

RufiS commented 11 years ago

Noticed that if I compare FFFFFFFFh and (8->F)**h ( represents DONTCARE value) with a comparator chip, they are equal. Also if i use a multiplier with no constant declared and no overflow bits, multiplying (00000001h x FFFFFFFFh) = 7FFFFFFFh, instead of FFFFFFFFh Also multiplying (7FFFFFFFh x FFFFFFFF) = 00000001 instead of 80000001. Also with the multiplier, (8***h x FFFFFFFFh) = 00000001h instead of 80000000.

compare: input pins 31->0: 1** input pins 63->32: 11111111111111111111111111111111 output pin 0: 0 output pin 1: 1 output pin 2: 0 Multiplier 32 input pins 31->0: 01 input pins 63->32: 11111111111111111111111111111111 output pins 31->0: 0******

signed int used as a variable in the plugin as opposed to an unsigned int??

I came across this while the computer i built with your plugin was doing a compare for the Bresenham's line algorithm function i wrote into the program memory. Also while I was multiplying DY x FFFFFFFFh (-1), the DY problem was however solved by inverting and adding 1. However the compare trouble has me stumped.

socram8888 commented 11 years ago

Yes, it uses a signed int basically because Java can't handle (natively) unsigned integers. It might be desirable to change it so it uses a BigInteger instead, so it could handle any word length.

socram8888 commented 11 years ago

By the way this issue should be opened in BasicCircuits, as RedstoneChips is just the API