Sha256: 0cc5af9a978d3f90aee05620afc4570d7b8762508f67093b75adcf8edd7b6e5e
Contents?: true
Size: 607 Bytes
Versions: 46
Compression:
Stored size: 607 Bytes
Contents
package s3.website object ByteHelper { // Adapted from http://stackoverflow.com/a/3758880/219947 def humanReadableByteCount(bytes: Long): String = { val si: Boolean = true val unit: Int = if (si) 1000 else 1024 if (bytes < unit) { bytes + " B" } else { val exp: Int = (Math.log(bytes) / Math.log(unit)).asInstanceOf[Int] val pre: String = (if (si) "kMGTPE" else "KMGTPE").charAt(exp - 1) + (if (si) "" else "i") val formatArgs = (bytes / Math.pow(unit, exp)).asInstanceOf[AnyRef] :: pre :: Nil String.format("%.1f %sB", formatArgs.toArray:_*) } } }
Version data entries
46 entries across 46 versions & 2 rubygems