MakeInteger() private method

private MakeInteger ( bool &fFraction ) : void
fFraction bool
return void
Beispiel #1
0
        // Floor - next largest integer smaller or equal to the numeric
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public static SqlDecimal Floor(SqlDecimal n)
        {
            n.AssertValid();

            if (n.IsNull)
                return SqlDecimal.Null;

            if (n.m_bScale == 0)
                return n;

            bool fFraction;    //Fractional flag

            n.MakeInteger(out fFraction);

            //When the numeric has fraction and is negative, subtract 1 by calling AddULong(1)
            //Otherwise return the integral part.
            if (fFraction && !n.IsPositive)
            {
                n.AddULong(1);
            }

            if (n.FZero())//if result is zero, sign should be positive
                n.SetPositive();
            n.AssertValid();
            return n;
        }
 public static SqlDecimal Floor(SqlDecimal n)
 {
     if (n.IsNull)
     {
         return Null;
     }
     if (n.m_bScale != 0)
     {
         bool flag;
         n.MakeInteger(out flag);
         if (flag && !n.IsPositive)
         {
             n.AddULong(1);
         }
         if (n.FZero())
         {
             n.SetPositive();
         }
     }
     return n;
 }