Skip to content

Commit

Permalink
Fully connected operands to bit panel
Browse files Browse the repository at this point in the history
  • Loading branch information
M4444 committed Nov 5, 2017
1 parent f1c9e20 commit 26e4818
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Binary file modified dist/C41C.jar
Binary file not shown.
24 changes: 20 additions & 4 deletions src/c41c/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -1140,17 +1140,21 @@ private void BUTTON_AddDigitActionPerformed(java.awt.event.ActionEvent evt) {//G
if(!OperationUnderway) {
newValue = Value.multiply(new BigInteger(Integer.toString(Base)))
.add(new BigInteger(button.getName(), Base));
if (newValue.compareTo(CurrentMaxInt) < 0)
if (newValue.compareTo(CurrentMaxInt) < 0) {
Value = newValue;
changeAllBits(Value);
}
} else {
if (!SecondOperandEntered) {
SecondOperand = BigInteger.ZERO;
SecondOperandEntered = true;
}
newValue = SecondOperand.multiply(new BigInteger(Integer.toString(Base)))
.add(new BigInteger(button.getName(), Base));
if (newValue.compareTo(CurrentMaxInt) < 0)
if (newValue.compareTo(CurrentMaxInt) < 0) {
SecondOperand = newValue;
changeAllBits(SecondOperand);
}
}

refreshTextArea();
Expand All @@ -1162,10 +1166,13 @@ private void BUTTON_RemoveDigitActionPerformed(java.awt.event.ActionEvent evt) {
if (OperationUnderway && !SecondOperandEntered)
return;

if(!OperationUnderway)
if(!OperationUnderway) {
Value = Value.divide(new BigInteger(Integer.toString(Base)));
else
changeAllBits(Value);
} else {
SecondOperand = SecondOperand.divide(new BigInteger(Integer.toString(Base)));
changeAllBits(SecondOperand);
}

refreshTextArea();
}//GEN-LAST:event_BUTTON_RemoveDigitActionPerformed
Expand All @@ -1175,6 +1182,7 @@ private void BUTTON_ClearCurrentActionPerformed(java.awt.event.ActionEvent evt)
Value = BigInteger.ZERO;
else
SecondOperand = BigInteger.ZERO;
changeAllBits(BigInteger.ZERO);
DivisionByZero = false;

refreshTextArea();
Expand Down Expand Up @@ -1215,6 +1223,11 @@ private void bitSwitch(JLabel bitLabel) {
refreshTextArea();
}

private void changeAllBits(BigInteger value) {
for (int i = 0; i < CurrentMaxInt.bitLength(); i++)
LABEL_bitGroup[i].setText(value.testBit(i) ? "1" : "0");
}

private void testTextArea() {
long start=System.currentTimeMillis();

Expand Down Expand Up @@ -1277,9 +1290,11 @@ else if (bitNum == 0)
CurrentMaxInt = BigInteger.ONE.shiftLeft(bitNum-1);
Value = Value.mod(CurrentMaxInt.shiftLeft(1));
Value = adjustForOverflow(Value);
changeAllBits(Value);
if(OperationUnderway) {
SecondOperand = SecondOperand.mod(CurrentMaxInt.shiftLeft(1));
SecondOperand = adjustForOverflow(SecondOperand);
changeAllBits(SecondOperand);
}
refreshTextArea();

Expand Down Expand Up @@ -1385,6 +1400,7 @@ private void performOperation() {
return;
}
Value = adjustForOverflow(Value);
changeAllBits(Value);

refreshTextArea();
}
Expand Down

0 comments on commit 26e4818

Please sign in to comment.