float16 function

double float16(
  1. int w
)

Implementation

double float16(int w) {
  final t = calloc<ffi.UnsignedInt>()..value = ((w & 0x7fff) << 13) + 0x38000000;
  final sign = calloc<ffi.UnsignedInt>()..value = (w & 0x8000) << 16;
  final e = calloc<ffi.UnsignedInt>()..value = w & 0x7c00;

  final out = calloc<cvg.Cv32suf_C>()..ref.u = t.value + (1 << 23);
  if (e.value >= 0x7c00) {
    out.ref.u = t.value + 0x38000000;
  } else {
    if (e.value == 0) {
      out.ref.f -= 6.103515625e-05;
    } else {
      out.ref.u = t.value;
    }
  }
  out.ref.u |= sign.value;
  final rval = out.ref.f;
  calloc.free(out);
  calloc.free(t);
  calloc.free(sign);
  calloc.free(e);
  return rval;
}