Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

Round off a number after a calculation.

Hi,

I am programming in VS2010 with C#.
I have this code:

            if (e.Column.FieldName == "Value")
            {
                if ((Properties.Settings.Default.IsMGDL == false) && (CheckType(e.Value.ToString()) == false))
                {
                    int eValue = Convert.ToInt32(e.Value) / 18;
                    e.DisplayText = (eValue).ToString();
                }
                else if ((Properties.Settings.Default.IsMGDL == true) && (CheckType(e.Value.ToString()) == true))
                {
                    double eValue = Convert.ToDouble(e.Value) * 18;
                    e.DisplayText = (eValue).ToString();
                }
            }

Open in new window


In the first condition the calculated number has to round up in 1 decimal after the period.
or in my case the comma (f.e: 6,66666 has to be 6,7)

And in the second condition the calculated number as to round up as a whole number.
(f.e: 6,66666 has to be 7)

I hope I have explained it right!

How can I do that?

Peter
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Kiers

ASKER

Thanks 500 p's comming to you...

Peter