Created
April 11, 2018 13:34
-
-
Save quiye/b09808212c2f692044069267fcd90914 to your computer and use it in GitHub Desktop.
4bytes => Float
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import java.nio.ByteBuffer | |
import java.nio.ByteBuffer | |
scala> val b = Array(1,2,3,4,5,6,7,8,0,0,0,0).map(_.toByte) | |
b: Array[Byte] = Array(1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0) | |
scala> b.grouped(4).foldRight(Nil: List[Float])(ByteBuffer.wrap(_).getFloat::_) | |
res8: List[Float] = List(2.3879393E-38, 6.301941E-36, 0.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment