/// <summary> /// Returns the n-th highest number less than this. /// </summary> /// <param name="steps">n</param> public static FloatPtr Preceding(this FloatPtr value, IntPtr steps) { if (FloatPtr.IsNegativeInfinity(value) || FloatPtr.IsNaN(value)) { return(value); } else if (FloatPtr.IsPositiveInfinity(value)) { return(Single.MaxValue); } var ptrRep = FloatPtr.FloatPtrToIntPtrBits(value); if ((long)ptrRep >= 0) { ptrRep = (IntPtr)((long)ptrRep - (long)steps); } else if (ptrRep == IntPtrMinValue) //-0 { ptrRep = steps; } else { ptrRep = (IntPtr)((long)ptrRep + (long)steps); } return(FloatPtr.IntPtrBitsToFloatPtr(ptrRep)); }
/// <summary> /// Returns the highest number less than this. /// </summary> public static FloatPtr Preceding(this FloatPtr value) { return(Preceding(value, (IntPtr)1)); }
/// <summary> /// Returns the smallest number greater than this. /// </summary> public static FloatPtr Following(this FloatPtr value) { return(Following(value, (IntPtr)1)); }