getHalfFloat method

double getHalfFloat(
  1. int val
)

Get a half-precision float from an integer value.

Implementation

double getHalfFloat(int val) {
  // Check for known patterns/anomalies and return
  // the correct values otherwise use the algorithm below.

  // Prefilter
  if (val == 1) {
    return 5.960464477539063e-8;
  }
  final ret = getHalfPrecisionDouble(val);
  // Post filter
  if (ret == 65536.0) {
    return double.infinity;
  }
  if (ret == -65536.0) {
    return -double.infinity;
  }
  if (ret == 98304.0) {
    return double.nan;
  }
  return ret;
}