Skip to content

Instantly share code, notes, and snippets.

@n1ckfg
Last active October 9, 2019 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1ckfg/695a9e217fd19b6d76849ba086527db0 to your computer and use it in GitHub Desktop.
Save n1ckfg/695a9e217fd19b6d76849ba086527db0 to your computer and use it in GitHub Desktop.
Represent a float in two bytes instead of four
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