Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
9
Task/Variable-size-Get/Scala/variable-size-get.scala
Normal file
9
Task/Variable-size-Get/Scala/variable-size-get.scala
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
def nBytes(x: Double) = ((Math.log(x) / Math.log(2) + 1e-10).round + 1) / 8
|
||||
|
||||
val primitives: List[(Any, Long)] =
|
||||
List((Byte, Byte.MaxValue),
|
||||
(Short, Short.MaxValue),
|
||||
(Int, Int.MaxValue),
|
||||
(Long, Long.MaxValue))
|
||||
|
||||
primitives.foreach(t => println(f"A Scala ${t._1.toString.drop(13)}%-5s has ${nBytes(t._2)} bytes"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue