unsafe extern "C" fn encode_half(mut val: libc::c_double) -> libc::c_ushort {
    let mut v: uint64_t = 0;
    let mut sign: libc::c_int = 0;
    let mut exp: libc::c_int = 0;
    let mut mant: libc::c_int = 0;
    memcpy(
        &mut v as *mut uint64_t as *mut libc::c_void,
        &mut val as *mut libc::c_double as *const libc::c_void,
        ::std::mem::size_of::<uint64_t>() as libc::c_ulong,
    );
    sign = (v >> 63i32 << 15i32) as libc::c_int;
    exp = (v >> 52i32 & 0x7ffi32 as libc::c_ulonglong) as libc::c_int;
    /* keep only the 11 most significant bits of the mantissa */
    mant = (v << 12i32 >> 12i32 >> 53i32 - 11i32) as libc::c_int;
    exp -= 1023i32;
    if exp == 1024i32 {
        /* infinity or NaN */
        exp = 16i32;
        mant >>= 1i32
    } else if exp >= 16i32 {
        /* overflow, as largest number */
        exp = 15i32;
        mant = 1023i32
    } else if !(exp >= -14i32) {
        /* regular normal */
        if exp >= -24i32 {
            /* subnormal */
            mant |= 1024i32;
            mant >>= -(exp + 14i32);
            exp = -15i32
        } else {
            return 0i32 as libc::c_ushort;
        }
    }
    /* safe cast here as bit operations above guarantee not to overflow */
    return (sign | exp + 15i32 << 10i32 | mant) as libc::c_ushort;
}
/* software implementation of float-to-fp16 conversions */
software implementation of float-to-fp16 conversions
software implementation of float - to - fp16 conversions
unsafe extern "C" fn encode_half(mut val: libc::c_double) -> libc::c_ushort {
    let mut v: uint64_t = 0;
    let mut sign: libc::c_int = 0;
    let mut exp: libc::c_int = 0;
    let mut mant: libc::c_int = 0;
    memcpy(
        &mut v as *mut uint64_t as *mut libc::c_void,
        &mut val as *mut libc::c_double as *const libc::c_void,
        ::std::mem::size_of::<uint64_t>() as libc::c_ulong,
    );
    sign = (v >> 63i32 << 15i32) as libc::c_int;
    exp = (v >> 52i32 & 0x7ffi32 as libc::c_ulonglong) as libc::c_int;
    /* keep only the 11 most significant bits of the mantissa */
    mant = (v << 12i32 >> 12i32 >> 53i32 - 11i32) as libc::c_int;
    exp -= 1023i32;
    if exp == 1024i32 {
        /* infinity or NaN */
        exp = 16i32;
        mant >>= 1i32
    } else if exp >= 16i32 {
        /* overflow, as largest number */
        exp = 15i32;
        mant = 1023i32
    } else if !(exp >= -14i32) {
        /* regular normal */
        if exp >= -24i32 {
            /* subnormal */
            mant |= 1024i32;
            mant >>= -(exp + 14i32);
            exp = -15i32
        } else {
            return 0i32 as libc::c_ushort;
        }
    }
    /* safe cast here as bit operations above guarantee not to overflow */
    return (sign | exp + 15i32 << 10i32 | mant) as libc::c_ushort;
}
unsafe extern " " fn encode_half ( mut val : libc :: c_double ) -> libc :: c_ushort { let mut v : uint64_t = 0 ; let mut sign : libc :: c_int = 0 ; let mut exp : libc :: c_int = 0 ; let mut mant : libc :: c_int = 0 ; memcpy ( & mut v as * mut uint64_t as * mut libc :: c_void , & mut val as * mut libc :: c_double as * const libc :: c_void , :: std :: mem :: size_of :: < uint64_t > ( ) as libc :: c_ulong , ) ; sign = ( v >> 63i32 << 15i32 ) as libc :: c_int ; exp = ( v >> 52i32 & 0x7ffi32 as libc :: c_ulonglong ) as libc :: c_int ; /* keep only the 11 most significant bits of the mantissa */ mant = ( v << 12i32 >> 12i32 >> 53i32 - 11i32 ) as libc :: c_int ; exp -= 1023i32 ; if exp == 1024i32 { /* infinity or NaN */ exp = 16i32 ; mant >>= 1i32 } else if exp >= 16i32 { /* overflow, as largest number */ exp = 15i32 ; mant = 1023i32 } else if ! ( exp >= - 14i32 ) { /* regular normal */ if exp >= - 24i32 { /* subnormal */ mant |= 1024i32 ; mant >>= - ( exp + 14i32 ) ; exp = - 15i32 } else { return 0i32 as libc :: c_ushort ; } } /* safe cast here as bit operations above guarantee not to overflow */ return ( sign | exp + 15i32 << 10i32 | mant ) as libc :: c_ushort ; }
software implementation of float-to-fp16 conversions
software implementation of float - to - fp16 conversions
val
libc::c_double