Skip to content

Commit

Permalink
Special case ceiling / floor for NaN, Inf, and -Inf.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed May 14, 2010
1 parent f3998c4 commit e988665
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/Num.pm
Expand Up @@ -79,12 +79,22 @@ augment class Num does Real {
~self;
}

method ceiling(Real $x:) {
pir::box__PI(pir::ceil__IN($x))
method ceiling(Num $x:) {
given $x {
when NaN { NaN }
when Inf { Inf }
when -Inf { -Inf }
pir::box__PI(pir::ceil__IN($x));
}
}

method floor(Real $x:) {
pir::box__PI(pir::floor__IN($x));
given $x {
when NaN { NaN }
when Inf { Inf }
when -Inf { -Inf }
pir::box__PI(pir::floor__IN($x));
}
}

method sqrt(Num $x:) {
Expand Down

0 comments on commit e988665

Please sign in to comment.