System.Data.SqlTypes.SqlDecimal.MakeInteger C# (CSharp) Method

MakeInteger() private method

private MakeInteger ( bool &fFraction ) : void
fFraction bool
return void
        private void MakeInteger(out bool fFraction)
        {
            uint ulRem;
            int iAdjust = _bScale;

            fFraction = false;

            while (iAdjust > 0)
            {
                if (iAdjust >= 9)
                {
                    ulRem = DivByULong(s_rgulShiftBase[8]);
                    iAdjust -= 9;
                }
                else
                {
                    ulRem = DivByULong(s_rgulShiftBase[iAdjust - 1]);
                    iAdjust = 0;
                }

                // Check for remainder and set fFraction flag.
                if (ulRem != 0)
                    fFraction = true;
            }

            _bScale = 0;
            AssertValid();
        }

Usage Example

Example #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;
        }
All Usage Examples Of System.Data.SqlTypes.SqlDecimal::MakeInteger