Skip to content

Commit d84af24

Browse files
committed
Fixed rounding in int -> float conversion
1 parent a318191 commit d84af24

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathGuards.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
public class MathGuards {
5151

5252
public static boolean fitLong(double value) {
53-
return Long.MIN_VALUE <= value && value <= Long.MAX_VALUE;
53+
return Long.MIN_VALUE < value && value < Long.MAX_VALUE;
5454
}
5555

5656
public static boolean fitInt(double value) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,17 @@ public void initialize(PythonCore core) {
142142
"\n[Graal, " + Truffle.getRuntime().getName() + ", Java " + System.getProperty("java.version") + "]");
143143
// the default values taken from JPython
144144
builtinConstants.put("float_info", core.factory().createTuple(new Object[]{
145-
Double.MAX_VALUE, // DBL_MAX
146-
Double.MAX_EXPONENT, // DBL_MAX_EXP
147-
308, // DBL_MIN_10_EXP
148-
Double.MIN_VALUE, // DBL_MIN
149-
Double.MIN_EXPONENT, // DBL_MIN_EXP
150-
-307, // DBL_MIN_10_EXP
151-
10, // DBL_DIG
152-
53, // DBL_MANT_DIG
153-
2.2204460492503131e-16, // DBL_EPSILON
154-
2, // FLT_RADIX
155-
1 // FLT_ROUNDS
145+
Double.MAX_VALUE, // DBL_MAX
146+
Double.MAX_EXPONENT + 1, // DBL_MAX_EXP
147+
308, // DBL_MIN_10_EXP
148+
Double.MIN_VALUE, // DBL_MIN
149+
Double.MIN_EXPONENT, // DBL_MIN_EXP
150+
-307, // DBL_MIN_10_EXP
151+
10, // DBL_DIG
152+
53, // DBL_MANT_DIG
153+
2.2204460492503131e-16, // DBL_EPSILON
154+
2, // FLT_RADIX
155+
1 // FLT_ROUNDS
156156
}));
157157
builtinConstants.put("maxunicode", IntegerFormatter.LIMIT_UNICODE.intValue() - 1);
158158

0 commit comments

Comments
 (0)