Skip to content

Commit

Permalink
IEEE kleine Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Muehle committed Oct 14, 2020
1 parent 35cc618 commit e3de1d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ public void setValue(String value, int baseOfValue) throws NullPointerException,
/** {@inheritDoc} */
@Override
public void setIEEE(String ieee, IEEEStandard standard) throws NullPointerException, NumberFormatException, IllegalArgumentException {
ieee = ieee.replaceAll(" ", "");
ieee = ieee.replace(" ", "");

//Vorzeichen und Standart
//Vorzeichen und Standard
boolean negIeee = ieee.startsWith("1");
boolean half = standard.equals(IEEEStandard.IEEE_754_2008_b16);
boolean single = standard.equals(IEEEStandard.IEEE_754_2008_b32);
Expand Down Expand Up @@ -554,6 +554,9 @@ public String toString() {
/** {@inheritDoc} */
@Override
public String toIEEEString(IEEEStandard standard) {
if(decValue.equals("")) {
return "";
}

boolean half = standard.equals(IEEEStandard.IEEE_754_2008_b16);

Expand All @@ -568,17 +571,17 @@ public String toIEEEString(IEEEStandard standard) {

//Vorzeichenbehandlung des übergebenen Strings
String vorzeichen = "0";
boolean isNegative = decValueOhne.startsWith("-");
boolean isNegative = decValueOhne.startsWith("-");
if(isNegative) {
vorzeichen = "1";
decValueOhne = decValueOhne.replaceFirst("-", "");

}
//TODO wenn , anstatt . verwendet wird !!

//TODO Sonderfälle für höchste und kleinste Zahl hinzufügen / Abfrage für höchste und kleinste Zahl ändern?
//TODO zu große und zu kleine Zahlen abfangen set aus SimpleChangeableNumber wird NumberOverflowException geworfen?
//Sonderfall +-0
if(Double.parseDouble(decValue) == 0) {
if(this.asDouble() == 0) {

if (half) {

Expand All @@ -595,7 +598,7 @@ public String toIEEEString(IEEEStandard standard) {
return vorzeichen + " " + sonderfallExp + " " + sonderfallMan;
}
//Sonderfall NaN
if(decValue.contentEquals("NaN")) {
if(decValue.equals("NaN")) {

if (half) {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/bitchanger/gui/controls/ValueField.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Tim M\u00FChle
*
* @since Bitchanger 0.1.0
* @version 0.1.6
* @version 0.1.9
*
*/
/* <!-- $LANGUAGE=EN -->
Expand All @@ -51,7 +51,7 @@
* @author Tim M\u00FChle
*
* @since Bitchanger 0.1.0
* @version 0.1.8
* @version 0.1.9
*
*/
public class ValueField extends TextField {
Expand Down

0 comments on commit e3de1d6

Please sign in to comment.