only:at least some progress with float numbers
This commit is contained in:
parent
ace25c8789
commit
7a901b5db8
|
@ -49,7 +49,8 @@ public class ScalarIniField extends IniField {
|
|||
public String getValue(ConfigurationImage image) {
|
||||
Field f = new Field(getName(), getOffset(), getType());
|
||||
try {
|
||||
return f.getValue(image, multiplier).toString();
|
||||
Double value = f.getValue(image, multiplier);
|
||||
return Field.niceToString(value, Field.FIELD_PRECISION);
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalStateException("While getting " + getName(), e);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import static com.rusefi.config.FieldType.*;
|
|||
|
||||
public class Field {
|
||||
public static final int NO_BIT_OFFSET = -1;
|
||||
private static final int FIELD_PRECISION = 3;
|
||||
public static final int FIELD_PRECISION = 7;
|
||||
|
||||
private final String name;
|
||||
private final int offset;
|
||||
|
@ -100,6 +100,8 @@ public class Field {
|
|||
Number number = value;
|
||||
if (number instanceof Float)
|
||||
return niceToString(number.floatValue(), precision);
|
||||
if (number instanceof Double)
|
||||
return niceToString(number.doubleValue(), precision);
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ public class TuneWriterTest {
|
|||
double value = 0.9;
|
||||
floatField.setValue(image, new Constant("x", "y", Double.toString(value), "2"));
|
||||
|
||||
assertEquals("0.8999999761581421", floatField.getValue(image));
|
||||
assertEquals("0.89999998", floatField.getValue(image));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class TuneReadWriteTest {
|
|||
|
||||
ConfigurationImage binaryDataFromXml = tuneFromFile.asImage(model, LEGACY_TOTAL_CONFIG_SIZE);
|
||||
|
||||
assertEquals(0, compareImages(binaryDataFromXml, fileBinaryData, model));
|
||||
assertEquals("Binary match expected", 0, compareImages(binaryDataFromXml, fileBinaryData, model));
|
||||
// todo: looks like this is not removing the temporary file?
|
||||
Files.delete(path);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue