tags:

views:

65

answers:

1

I need to sum 2 decimal values together, then divide by 2 and convert to string.

My calculation currently is trimming to 2 decimal places, but I want to keep as many decimals as I can.

city.Latitude = ( (lat.North + lat.South) / 2 ).ToString();

the values for lat.North and lat.South are like: 55.32342322

+1  A: 

See here:

Standard Numeric Format Strings
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

You probably want to specify a "G" or "F" format specifier in this overload of the ToString() method.

Robert Harvey
He also likely wants to make `city.Latitude` a decimal, since it does store decimal values and not string values.
ANeves