Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NETVB-一些与.NET有关的数学知识_.net_Algorithm_Math - Fatal编程技术网

ASP.NETVB-一些与.NET有关的数学知识

ASP.NETVB-一些与.NET有关的数学知识,.net,algorithm,math,.net,Algorithm,Math,我需要你的帮助 例如,我有一个decimal类型的变量,我想用这种方式进行取整 乙二醇 3.0=3 3.1=4 3.2=4 3.3=4 3.4=4 3.5=4 3.6=4 3.7=4 3.8=4 3.9=4 4.0=4 4.1=5 4.2=5 等等 我该怎么做呢?数学天花板数学天花板 dim rounded as int = Math.Ceiling(4.1) VB语法有点生疏,所以它可能不是完美的、可编译的语法 VB语法有点生疏,所以它可能不是完美的、可编译的语法也许您必须解析为char,并

我需要你的帮助

例如,我有一个decimal类型的变量,我想用这种方式进行取整

乙二醇

3.0=3

3.1=4

3.2=4

3.3=4

3.4=4

3.5=4

3.6=4

3.7=4

3.8=4

3.9=4

4.0=4

4.1=5

4.2=5

等等


我该怎么做呢?

数学天花板

数学天花板

dim rounded as int = Math.Ceiling(4.1)
VB语法有点生疏,所以它可能不是完美的、可编译的语法


VB语法有点生疏,所以它可能不是完美的、可编译的语法

也许您必须解析为char,并且必须检查desimal值。。。 a=3.4 stra=cstra b=子串A,0,1 c=子串A,2,1

d=cintc e=cintb

如果d>0,则 e+=1
如果

可能您必须解析为char,并且必须检查desimal值。。。 a=3.4 stra=cstra b=子串A,0,1 c=子串A,2,1

d=cintc e=cintb

如果d>0,则 e+=1
end if

非常简单,诀窍在于大多数编程提供的上限函数。例如,在C中,它是数学名称空间中的staic方法

名称空间控制台窃听器 { 班级计划 { 静态环[]args { int-lowerLimit=3; int上限=10

        int index = 0;
        for (int i = lowerLimit; i < upperLimit; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                string value = i + "." + j;
                Console.WriteLine( value + "  " + Round(double.Parse(value)));
            }

            if (index == 10)
                index = 0;
        }
        Console.ReadLine();
    }

    private static double Round(double number)
    {
        return Math.Ceiling(number);
    }
}

}

非常简单,诀窍在于大多数编程提供的上限函数。例如,在C中,它是数学名称空间中的staic方法

名称空间控制台窃听器 { 班级计划 { 静态环[]args { int-lowerLimit=3; int上限=10

        int index = 0;
        for (int i = lowerLimit; i < upperLimit; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                string value = i + "." + j;
                Console.WriteLine( value + "  " + Round(double.Parse(value)));
            }

            if (index == 10)
                index = 0;
        }
        Console.ReadLine();
    }

    private static double Round(double number)
    {
        return Math.Ceiling(number);
    }
}
}