相关疑难解决方法(0)

C#中的任意精度小数?

是否有可用于C#的任意精度十进制类?我已经看过几个任意精度整数类,但这并不完全相同.

c# math

7
推荐指数
1
解决办法
2848
查看次数

如何在 Pi 的 C# 程序中获得小数到 n 位精度

用 reg 这个问题 Pi in C#

我编写了下面的代码并给出了最后 6 位为 0 的输出。所以我想通过将所有内容转换为十进制来改进程序。我以前从未在 C# 中使用过十进制而不是双精度数,而且我只在常规使用中对双精度数感到满意。

所以请帮助我进行十进制转换,我尝试在开始时将所有双精度替换为十进制,但效果不佳:(。

 using System;

class Program
{
    static void Main()
    {
    Console.WriteLine(" Get PI from methods shown here");
    double d = PI();
    Console.WriteLine("{0:N20}",
        d);

    Console.WriteLine(" Get PI from the .NET Math class constant");
    double d2 = Math.PI;
    Console.WriteLine("{0:N20}",
        d2);
    }

    static double PI()
    {
    // Returns PI
    return 2 * F(1);
    }

    static double F(int i)
    {
    // Receives the call number
   //To avoid so error
    if (i …
Run Code Online (Sandbox Code Playgroud)

c# precision pi decimal

3
推荐指数
1
解决办法
2481
查看次数

标签 统计

c# ×2

decimal ×1

math ×1

pi ×1

precision ×1