Math.round 方法将数千变成数百

Math.round method turns thousands into hundreds

我正在尝试创建一个与地图相关的计算器,但我在使用 Math.Round 方法时遇到了问题。基本上,我希望程序采用现实生活中的长度和地图上的长度来计算所述地图的比例尺。在计算出比例后,它应该将其从双精度四舍五入为整数。 因此,例如,现实生活中的长度是 3000000 厘米,地图上的长度等于 8.5 厘米,除以这些后,我们得到 352 941,176,这就是我们在这种情况下的比例。现在四舍五入后,比例应该是 1:352 941 但程序给了我 1:352.

的比例
 double Scalenoteven;
 int Scaleeven;

//RealLengthincm and Maplength are taken from the user 
  Scalenoteven = RealLengthincm / MapLength;
  Scaleeven = (int)Math.Round(Scalenoteven, 1, MidpointRounding.ToEven);

因此,添加了文化信息和 RealLengthincm = RealLength * 100; 这应该可行。

using System.Globalization;

double RealLength;
string RealLengthString;
double MapLength;
string MapLengthString;
double RealLengthincm;
double Scalenoteven;
int Scaleeven;

Console.WriteLine("Firstly will the real length be in meters or kilometers?");
string Answer;
Answer = Console.ReadLine();

if (Answer == "meters")
{
    Console.WriteLine("Alright!");
    Console.WriteLine("So what's the real length?");

    var culture = new CultureInfo("de-DE");

    RealLengthString = Console.ReadLine(); // assuming 30000
    RealLength = double.Parse(RealLengthString, culture);

    RealLengthincm = RealLength * 100;
    Console.WriteLine("now what's the length on the map in cm");

    MapLengthString = Console.ReadLine(); // assuming 8,5
    MapLength = double.Parse(MapLengthString, culture);

    //RealLengthincm and Maplength are taken from the user 
    Scalenoteven = RealLengthincm / MapLength;
    Scaleeven = (int)Math.Round(Scalenoteven, 0, MidpointRounding.ToZero);
    Console.WriteLine("The Scale is 1:" + Scaleeven); // outputs 1:352941
}