4 ms·
Scala has bitewise operators http://www.tutorialspoint.com/scala/scala_bitwise_operators.htm http://www.tutorialspoint.com/scala/scala_bitwise_operators.... S
by brianwawok 11y ago
Scala has bitewise operators
http://www.tutorialspoint.com/scala/scala_bitwise_operators.htm http://www.tutorialspoint.com/scala/scala_bitwise_operators....
So the "<<" is easy enough to cover.
I do not know what the * is going, if it involves pointer something something then it may not be possible to replicate.
- cozzyd 11y agoI'm just reinterpreting the 64-bit integer as a double-precision floating point number (there are other ways to do this in C, for example using a union).
- shanemhansen 11y agoJava has a type called bytebuffer that might do the trick: http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html#getFloat() http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer... I don't know how that would get optimized by the jit at runtime though.
- jdmichal 11y agoDon't be silly. These functions are built into `Float` and `Double`. http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#doubleToRawLongBits%28double%29 http://docs.oracle.com/javase/7/docs/api/java/lang/Double.ht... http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#longBitsToDouble%28long%29 http://docs.oracle.com/javase/7/docs/api/java/lang/Double.ht... Both are marked as native functions in OpenJDK 7: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/lang/Double.java#Double.doubleToRawLongBits%28double%29 http://grepcode.com/file/repository.grepcode.com/java/root/j... http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/lang/Double.java#Double.longBitsToDouble%28long%29 http://grepcode.com/file/repository.grepcode.com/java/root/j...