All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scalapb.textformat.NumberUtils.scala Maven / Gradle / Ivy

package scalapb.textformat

private[scalapb] object NumberUtils {
  def doubleToString(v: Double): String = {
    import scalajs.js.JSNumberOps._
    val t = if (v.abs >= 1e7) { v.toExponential() }
    else if (v.isWhole) (v.toString + ".0")
    else v.toString
    t.replace("e-", "E-")
      .replace("e+", "E")
  }

  def floatToString(v: Float): String = {
    doubleToString(v.toDouble)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy