Exemple #1
0
 /// <summary>
 /// ������תFixed
 /// </summary>
 /// <param name="val"></param>
 /// <returns></returns>
 public static FIXED FloatToFixed(float val)
 {
     FIXED fix = new FIXED();
     fix.value = (short)val;
     long l = (long)Math.Round(val * 0xFFFF, MidpointRounding.AwayFromZero);
     fix.fract = (ushort)(l % 0xFFFF);
     return fix;
 }
Exemple #2
0
        /// <summary>
        /// 单精度转Fixed
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static FIXED FloatToFixed(float val)
        {
            FIXED fix = new FIXED();

            fix.value = (short)val;
            long l = (long)Math.Round(val * 0xFFFF, MidpointRounding.AwayFromZero);

            fix.fract = (ushort)(l % 0xFFFF);
            return(fix);
        }
Exemple #3
0
 /// <summary>
 /// Fixedת������
 /// </summary>
 /// <param name="val"></param>
 /// <returns></returns>
 public static float FixedToFloat(FIXED val)
 {
     float f = val.value + (float)val.fract / 0xFFFF;
     return f;
 }
Exemple #4
0
        /// <summary>
        /// Fixed转单精度
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static float FixedToFloat(FIXED val)
        {
            float f = val.value + (float)val.fract / 0xFFFF;

            return(f);
        }