Skip to content
Permalink
Browse files
[Truffle] Extreme bounds checking for Float#round.
  • Loading branch information
nirvdrum committed Dec 18, 2014
1 parent d56d246 commit a851478154fb575c3022c679bdb74041dd72ea38
Showing with 8 additions and 0 deletions.
  1. +8 −0 core/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
@@ -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) {

0 comments on commit a851478

Please sign in to comment.