public static int FloatToInt2(float f) { FloatAndUIntUnion f2i = default(FloatAndUIntUnion); f2i.FloatValue = f; // write as float return(f2i.Int32Bits); // read back as int }
public static float IntToFloat(int v) { FloatAndUIntUnion f2i = default(FloatAndUIntUnion); f2i.Int32Bits = v; return(f2i.FloatValue); }
public static float ReadSingle(System.IO.BinaryReader reader) { FloatAndUIntUnion v = default(FloatAndUIntUnion); v.UInt32Bits = ReadUInt32(reader); return(v.FloatValue); }
public static void Write(System.IO.BinaryWriter writer, float value) { FloatAndUIntUnion v = default(FloatAndUIntUnion); v.FloatValue = value; Write(writer, v.UInt32Bits); }