Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/core/IronPython/Modules/Builtin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/IronPython/Runtime/Operations/FloatOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}