mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
JS: reduce precision of float constants
This commit is contained in:
parent
a1aa25afa0
commit
3d96616761
|
@ -216,14 +216,14 @@ public class TFloat extends TNumber implements TComparable<TFloat> {
|
|||
}
|
||||
|
||||
private static float decimalExponent(int n) {
|
||||
float d;
|
||||
double d;
|
||||
if (n < 0) {
|
||||
d = 0.1f;
|
||||
d = 0.1;
|
||||
n = -n;
|
||||
} else {
|
||||
d = 10;
|
||||
}
|
||||
float result = 1;
|
||||
double result = 1;
|
||||
while (n != 0) {
|
||||
if (n % 2 != 0) {
|
||||
result *= d;
|
||||
|
@ -231,7 +231,7 @@ public class TFloat extends TNumber implements TComparable<TFloat> {
|
|||
d *= d;
|
||||
n /= 2;
|
||||
}
|
||||
return result;
|
||||
return (float) result;
|
||||
}
|
||||
|
||||
public static TFloat valueOf(TString s) throws TNumberFormatException {
|
||||
|
|
|
@ -231,10 +231,10 @@ public class RenderingContext {
|
|||
float value = (Float) cst;
|
||||
if (value < 0) {
|
||||
writer.append("(");
|
||||
writer.append(Float.toString(value));
|
||||
writer.append(Double.toString((double) value));
|
||||
writer.append(")");
|
||||
} else {
|
||||
writer.append(Float.toString(value));
|
||||
writer.append(Double.toString((double) value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user