2

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
  • 41,875
  • 56
  • 175
  • 268

1 Answers1

3

It's part of the Java Math library:

scala> java.lang.Math.nextAfter(2.0,3)
res0: Double = 2.0000000000000004
Rex Kerr
  • 162,454
  • 26
  • 308
  • 402