diff --git a/src/core/IronPython/Modules/Builtin.cs b/src/core/IronPython/Modules/Builtin.cs index 92d81bbd9..372955d65 100644 --- a/src/core/IronPython/Modules/Builtin.cs +++ b/src/core/IronPython/Modules/Builtin.cs @@ -1313,6 +1313,10 @@ public static object repr(CodeContext/*!*/ context, object? o) return DoubleOps.__round__(d); } + if (number is float f) { + return SingleOps.__round__(f); + } + if (number is int i) { return Int32Ops.__round__(i); } @@ -1338,6 +1342,9 @@ public static object repr(CodeContext/*!*/ context, object? o) if (number is double d) { return DoubleOps.__round__(d, ndi); } + if (number is float f) { + return SingleOps.__round__(f, ndi); + } if (number is int i) { return Int32Ops.__round__(i, ndi); } @@ -1350,6 +1357,9 @@ public static object repr(CodeContext/*!*/ context, object? o) if (number is double d) { return DoubleOps.__round__(d, ndbi); } + if (number is float f) { + return SingleOps.__round__(f, ndbi); + } if (number is int i) { return Int32Ops.__round__(i, ndbi); } diff --git a/src/core/IronPython/Runtime/Operations/FloatOps.cs b/src/core/IronPython/Runtime/Operations/FloatOps.cs index a086f5e62..bc3f076ef 100644 --- a/src/core/IronPython/Runtime/Operations/FloatOps.cs +++ b/src/core/IronPython/Runtime/Operations/FloatOps.cs @@ -1187,5 +1187,9 @@ public static int __hash__(float x) { public static double __float__(float x) { return x; } + + public static object __round__(float self) => DoubleOps.__round__(self); + + public static float __round__(float self, object ndigits) => (float)DoubleOps.__round__(self, ndigits); } }