Last active
October 9, 2019 04:26
-
-
Save n1ckfg/695a9e217fd19b6d76849ba086527db0 to your computer and use it in GitHub Desktop.
Represent a float in two bytes instead of four
This file contains 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
short places = 1000; | |
float foo = -11.14175; | |
short bar = (short) (foo * places); | |
float foo2 = (float) bar / (float) places; | |
println(foo + " " + foo2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment