Skip to content

Commit

Permalink
Fixed and streamlined bitSwitch()
Browse files Browse the repository at this point in the history
  • Loading branch information
M4444 committed Nov 5, 2017
1 parent 955afbe commit 32b2f9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
Binary file modified dist/C41C.jar
Binary file not shown.
29 changes: 5 additions & 24 deletions src/c41c/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -1197,30 +1197,11 @@ private void bitSwitch(JLabel bitLabel) {
String bit = bitLabel.getText();
int bitPos = Integer.parseInt(bitLabel.getName());

BigInteger value = BigInteger.ONE.shiftLeft(bitPos);
if(bit.equals("1")) {
if(!OperationUnderway)
Value = Value.subtract(value);
else {
if (!SecondOperandEntered) {
SecondOperator = BigInteger.ZERO;
SecondOperandEntered = true;
}
SecondOperator = SecondOperator.subtract(value);
}
bitLabel.setText("0");
} else if(bit.equals("0")) {
if(!OperationUnderway)
Value = Value.add(value);
else {
if (!SecondOperandEntered) {
SecondOperator = BigInteger.ZERO;
SecondOperandEntered = true;
}
SecondOperator = SecondOperator.add(value);
}
bitLabel.setText("1");
}
if(!OperationUnderway)
Value = Value.flipBit(bitPos);
else
SecondOperator = SecondOperator.flipBit(bitPos);
bitLabel.setText(bit.equals("1") ? "0" : "1");

//setSize(new java.awt.Dimension(386, 396));
refreshTextArea();
Expand Down

0 comments on commit 32b2f9f

Please sign in to comment.