Scala中与Go的math.Nextafter相等的函数是什么?

huangapple go评论139阅读模式
英文:

The Scala equivalent to Go's math.Nextafter

问题

我想知道Scala或者它的一些著名的数学库(例如Spire)是否有类似于Go的math.Nextafter函数的等价物。

  1. package main
  2. import (
  3. "fmt"
  4. "math"
  5. )
  6. func main() {
  7. fmt.Printf("现在你有%g个问题。",
  8. math.Nextafter(2, 3))
  9. }

(来自http://tour.golang.org/#4)

如果没有的话,最“Scala”的方法是什么来实现相同的功能?

英文:

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

  1. package main
  2. import (
  3. "fmt"
  4. "math"
  5. )
  6. func main() {
  7. fmt.Printf("Now you have %g problems.",
  8. math.Nextafter(2, 3))
  9. }

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

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

答案1

得分: 4

这是Java的Math库的一部分:

  1. scala> java.lang.Math.nextAfter(2.0,3)
  2. res0: Double = 2.0000000000000004
英文:

It's part of the Java Math library:

  1. scala> java.lang.Math.nextAfter(2.0,3)
  2. res0: Double = 2.0000000000000004

huangapple
  • 本文由 发表于 2013年7月22日 23:34:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/17791665.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定