Beispiel #1
0
        public static FixedPoint Round(FixedPoint fp)
        {
            var integer   = fp.Value >> FixedPoint.Q;
            var remainder = fp.Value - (integer << FixedPoint.Q);

            return(remainder >= FixedPoint.Half.Value
                ? FixedPoint.FromExplicit((integer + 1) << FixedPoint.Q)
                : FixedPoint.FromExplicit(integer << FixedPoint.Q));
        }
Beispiel #2
0
        public static FixedPoint Ceiling(FixedPoint fp)
        {
            var integer   = fp.Value >> FixedPoint.Q;
            var remainder = fp.Value - (integer << FixedPoint.Q);

            return(remainder > 0
                ? FixedPoint.FromExplicit((integer + 1) << FixedPoint.Q)
                : FixedPoint.FromExplicit(integer << FixedPoint.Q));
        }
Beispiel #3
0
 public static FixedPoint Floor(FixedPoint fp)
 {
     return(FixedPoint.FromExplicit((fp.Value >> FixedPoint.Q) << FixedPoint.Q));
 }
Beispiel #4
0
 public static FixedPoint Clamp(FixedPoint value, FixedPoint min, FixedPoint max)
 {
     return(FixedPoint.FromExplicit(Math.Clamp(value.Value, min.Value, max.Value)));
 }