LessThanOrClose() public static method

LessThanOrClose - Returns whether or not the first double is less than or close to the second double. That is, whether or not the first is strictly less than or within epsilon of the other number. Note that this epsilon is proportional to the numbers themselves to that AreClose survives scalar multiplication. Note, There are plenty of ways for this to return false even for numbers which are theoretically identical, so no code calling this should fail to work if this returns false. This is important enough to repeat: NB: NO CODE CALLING THIS FUNCTION SHOULD DEPEND ON ACCURATE RESULTS - this should be used for optimizations *only*.
public static LessThanOrClose ( double value1, double value2 ) : bool
value1 double The first double to compare.
value2 double The second double to compare.
return bool
 public static bool IsBetweenZeroAndOne(double val)
 {
     if (DoubleUtil.GreaterThanOrClose(val, 0.0))
     {
         return(DoubleUtil.LessThanOrClose(val, 1.0));
     }
     return(false);
 }
Example #2
0
        /// <summary>
        /// Creates an instances of <see cref="DpiScale2"/> from PPI values.
        /// </summary>
        /// <param name="ppiX">PPI along X-axis</param>
        /// <param name="ppiY">PPI along Y-axis</param>
        /// <returns>A new <see cref="DpiScale2"/> instance</returns>
        internal static DpiScale2 FromPixelsPerInch(double ppiX, double ppiY)
        {
            if (DoubleUtil.LessThanOrClose(ppiX, 0) || DoubleUtil.LessThanOrClose(ppiY, 0))
            {
                return(null);
            }

            return(new DpiScale2(ppiX / DpiUtil.DefaultPixelsPerInch, ppiY / DpiUtil.DefaultPixelsPerInch));
        }