3

I was wondering if Scala or one of its well known math libraries (e.g. Spire) has an equivalent to Go's math.Nextafter function

package main

import (
    "fmt"
    "math"
)

func main() {
    fmt.Printf("Now you have %g problems.",
        math.Nextafter(2, 3))
}

(From http://tour.golang.org/#4)

And if not, what is the most "Scala" way to get the same functionality?

Eran Medan
  • 44,555
  • 61
  • 184
  • 276

1 Answers1

4

It's part of the Java Math library:

scala> java.lang.Math.nextAfter(2.0,3)
res0: Double = 2.0000000000000004
Rex Kerr
  • 166,841
  • 26
  • 322
  • 407