相关疑难解决方法(0)

如何在不安装Ms Office的情况下在C#中创建Excel(.XLS和.XLSX)文件?

如何使用C#创建Excel电子表格而无需在运行代码的计算机上安装Excel?

.net c# excel file-io

1804
推荐指数
37
解决办法
105万
查看次数

在C#中舍入double值

我想在C#中对double值进行舍入方法.它需要能够将double值舍入到任何舍入精度值.我手边的代码看起来像:

public static double RoundI(double number, double roundingInterval) {

    if (roundingInterval == 0.0)
    {
        return;
    }

    double intv = Math.Abs(roundingInterval);
    double sign = Math.Sign(number);
    double val = Math.Abs(number);

    double valIntvRatio = val / intv;
    double k = Math.Floor(valIntvRatio);
    double m = valIntvRatio - k;

    bool mGreaterThanMidPoint = ((m - 0.5) >= 1e-14) ? true : false;
    bool mInMidpoint = (Math.Abs(m - 0.5) < 1e-14) ? true : false;
    return (mGreaterThanMidPoint || mInMidpoint) ? sign * ((k + 1) * intv) …
Run Code Online (Sandbox Code Playgroud)

c# double rounding

30
推荐指数
2
解决办法
5万
查看次数

在C++中截断

今天我试着编写一个程序来总结用户输入的整数.例如,如果用户输入683它将返回6 + 8 + 3 = 17.

但我在代码中遇到了一些奇怪的问题

代码 :

#包括

using namespace std;
int computeSum(int num);
int computeInteger(int num, int position);

int main()
{
    int num;
    int sum;
    int total;
    cin >> num;

    total = computeSum(num);

    cout << total;
    return 0;
}

int computeSum(int num) 
{
    int position = 10;
    int temp = num;
    double total = 0;
    bool finish = false;

    while(!finish)
    {
        total = total + computeInteger(num, position);

        if(num/ position == 0)
            break;
        position *= …
Run Code Online (Sandbox Code Playgroud)

c++ floating-point truncation

0
推荐指数
2
解决办法
1165
查看次数

标签 统计

c# ×2

.net ×1

c++ ×1

double ×1

excel ×1

file-io ×1

floating-point ×1

rounding ×1

truncation ×1