Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b8f531d911a7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5ec42398ad69
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Nov 3, 2014

  1. Copy the full SHA
    ab83937 View commit details

Commits on Nov 4, 2014

  1. Merge pull request #2086 from cheald/next_prev_float

    Add Float#next_float and Float#prev_float
    headius committed Nov 4, 2014
    Copy the full SHA
    5ec4239 View commit details
Showing with 11 additions and 0 deletions.
  1. +11 −0 core/src/main/java/org/jruby/RubyFloat.java
11 changes: 11 additions & 0 deletions core/src/main/java/org/jruby/RubyFloat.java
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import java.lang.Math;

import org.jcodings.specific.ASCIIEncoding;
import org.jcodings.specific.USASCIIEncoding;
@@ -978,4 +979,14 @@ public static RubyFloat unmarshalFrom(UnmarshalStream input) throws java.io.IOEx
private static final ByteList NAN_BYTELIST = new ByteList("nan".getBytes());
private static final ByteList NEGATIVE_INFINITY_BYTELIST = new ByteList("-inf".getBytes());
private static final ByteList INFINITY_BYTELIST = new ByteList("inf".getBytes());

@JRubyMethod(name = "next_float")
public IRubyObject next_float() {
return RubyFloat.newFloat(getRuntime(), Math.nextAfter(value, Double.POSITIVE_INFINITY));
}

@JRubyMethod(name = "prev_float")
public IRubyObject prev_float() {
return RubyFloat.newFloat(getRuntime(), Math.nextAfter(value, Double.NEGATIVE_INFINITY));
}
}