Skip to content

Commit

Permalink
[Truffle] Extreme bounds checking for Float#round.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Dec 18, 2014
1 parent d56d246 commit a851478
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -575,6 +575,14 @@ public RoundNode(RoundNode prev) {
public Object round(double n) {
// Algorithm copied from JRuby - not shared as we want to branch profile it

if (Double.isInfinite(n)) {
throw new RaiseException(getContext().getCoreLibrary().floatDomainError("Infinity", this));
}

if (Double.isNaN(n)) {
throw new RaiseException(getContext().getCoreLibrary().floatDomainError("NaN", this));
}

double f = n;

if (f > 0.0) {
Expand Down

0 comments on commit a851478

Please sign in to comment.