mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-22 20:01:09 -04:00
fixes a rounding issue
This commit is contained in:
parent
f0a1b16e9a
commit
c7310eff28
@ -225,9 +225,9 @@ public final class Bits {
|
||||
private static long decodeFixed(String str) throws NumberFormatException {
|
||||
int p = str.indexOf(':');
|
||||
try {
|
||||
int frac = Integer.parseInt(str.substring(p + 1));
|
||||
int frac = Math.abs(Integer.parseInt(str.substring(p + 1)));
|
||||
double floating = Double.parseDouble(str.substring(0, p));
|
||||
return (long) (floating * (1L << frac));
|
||||
return Math.round(floating * (1L << frac));
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
throw new NumberFormatException(str, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user