title: Half-precision floating-point in Java
body: <p>Is there a Java library anywhere that can perform computations on <a href="http://en.wikipedia.org/wiki/Half_precision_floating-point_format" rel="noreferrer">IEEE 754 half-precision</a> numbers or convert them to and from double-precision?</p>
  
  <p>Either of these approaches would be suitable:</p>
  
  <ul>
  <li>Keep the numbers in half-precision format and compute using integer arithmetic &amp; bit-twiddling (as <a href="http://www.dclausen.net/projects/microfloat/" rel="noreferrer">MicroFloat</a> does for single- and double-precision)</li>
  <li>Perform all computations in single or double precision, converting to/from half precision for transmission (in which case what I need is well-tested conversion functions.)</li>
  </ul>
  
  <hr>
  
  <p><strong>Edit</strong>: conversion needs to be 100% accurate - there <em>are</em> lots of NaNs, infinities and subnormals in the input files.</p>
  
  <hr>
  
  <p>Related question but for JavaScript: <a href="https://stackoverflow.com/questions/5678432/decompressing-half-precision-floats-in-javascript">Decompressing Half Precision Floats in Javascript</a></p>