diff --git a/src/core/Int.pm b/src/core/Int.pm index ad618ccde76..b0a67c30abb 100644 --- a/src/core/Int.pm +++ b/src/core/Int.pm @@ -69,6 +69,7 @@ my class Int does Real { # declared in BOOTSTRAP method ceiling(Int:D:) { self } proto method round(|) {*} multi method round(Int:D:) { self } + multi method round(Int:D: 1) { self } multi method round(Int:D: $scale as Real) { (self / $scale + 1/2).floor * $scale } method lsb(Int:D:) { diff --git a/src/core/Real.pm b/src/core/Real.pm index a9fcf72b7e8..02a198c38ff 100644 --- a/src/core/Real.pm +++ b/src/core/Real.pm @@ -38,8 +38,18 @@ my role Real does Numeric { method acotanh() { self.Bridge.acotanh } method floor() { self.Bridge.floor } method ceiling() { self.Bridge.ceiling } - # cannot use '0.5' here, because Rat isn't initialized yet - method round($scale as Real = 1) { (self / $scale + 1/2).floor * $scale } + + proto method round(|) { * } + multi method round(Real:D:) { + (self + 1/2).floor; # Rat NYI here, so no .5 + } + multi method round(Real:D: 1) { + (self + 1/2).floor; + } + multi method round(Real:D: $scale as Real) { + (self / $scale + 1/2).floor * $scale; + } + method unpolar(Real $angle) { Complex.new(self * $angle.cos, self * $angle.sin); }