SoFunction
Updated on 2025-03-07

C# rounding (function) usage example


public static double Round(double d, int i)
        {
            if (d >= 0)
            {
d += 5 * (10, -(i + 1));// Find the specified power of the specified number of times
            }
            else
            {
                d += 5 * (10, -(i + 1));
            }
            string str = ();
            string[] strs = ('.');
            int idot = ('.');
            string prestr = strs[0];
            string poststr = strs[1];
            if ( > i)
            {
poststr = (idot + 1, i);//Intercept the required number of digits
            }
            if ( <= 2)
            {
                poststr = poststr + "0";
            }
            string strd = prestr + "." + poststr;
d = (strd);//Convert string to double precision real number
            return d;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            =(((()),Convert.ToInt16(())));
        }