简体   繁体   English

是否有可能在c#中处理复杂数据类型的更高精度?

[英]Is there any possibility to deal with larger precision of Complex data type in c#?

I'm writing program which use complex data type, but it's too small for my problem. 我正在编写使用复杂数据类型的程序,但它对我的问题来说太小了。 I know it's just double data type for both real and imaginary members, but is it possible to keep numbers as big as 10^30? 我知道它只是真实和虚构成员的双重数据类型,但是有可能保持数字大到10 ^ 30吗? I was thinking about about connecting complex struct with big integer type (because I don't use floating-point numbers), but don't know how to do it. 我正在考虑将复杂结构与大整数类型连接(因为我不使用浮点数),但不知道如何去做。

将数字作为字符串进行操作,并逐位计算长计算。

I solved the problem. 我解决了这个问题。 I made a structure with two BigInteger members, one for real and second for imaginary part. 我用两个BigInteger成员构建了一个结构,一个用于实数,另一个用于虚部。 Ofc this solution need to create new functions for complex operations. 这个解决方案需要为复杂的操作创建新的功能。 For example adding 2 Complex (I named struct as "BigComplex") 例如,添加2个Complex(我将struct命名为“BigComplex”)

BigComplex add(BigComplex x, BigComplex y)
{
    BigComplex z;
    z.Real = x.Real + y.Real;
    z.Imaginary = x.Imaginary + y.Imaginary;
    return z;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM