public static Half SingleToHalf(float single) { var bytes = BitConverter.GetBytes(single); var value = BitConverter.ToUInt32(bytes, 0); #endif ushort result = (ushort)(baseTable[(value >> 23) & 0x1ff] + ((value & 0x007fffff) >> shiftTable[value >> 23])); return(Half.ToHalf(result)); }
public static Half SingleToHalf(float single) { buffer.WriteSingle(single, 0); var value = buffer.ReadUInt32(0); #endif #endif ushort result = (ushort)(baseTable[(value >> 23) & 0x1ff] + ((value & 0x007fffff) >> shiftTable[value >> 23])); return(Half.ToHalf(result)); }
public Half ReadHalf() { return(Half.ToHalf(reader.ReadUInt16())); }
public static Half Abs(Half half) { return(Half.ToHalf((ushort)(half.value & 0x7fff))); }
public static Half Negate(Half half) { return(Half.ToHalf((ushort)(half.value ^ 0x8000))); }