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