t*****s 发帖数: 49 | 1 请问有没有什么方法可以定义和使用更长的实数而不使去精度, 比如
计算 1。111111111111111112e20 - 1.111111111111111111e20 (小数点后18位)
多谢帮助 |
c****p 发帖数: 6474 | 2 数组计算?
【在 t*****s 的大作中提到】 : 请问有没有什么方法可以定义和使用更长的实数而不使去精度, 比如 : 计算 1。111111111111111112e20 - 1.111111111111111111e20 (小数点后18位) : 多谢帮助
|
f**l 发帖数: 2041 | 3 Mathematica can do that, if your computation is not heavy.
【在 t*****s 的大作中提到】 : 请问有没有什么方法可以定义和使用更长的实数而不使去精度, 比如 : 计算 1。111111111111111112e20 - 1.111111111111111111e20 (小数点后18位) : 多谢帮助
|
t*****s 发帖数: 49 | 4 thanks a lot for the reply. But is there anyway to solve the problem in C++ ? |
M**********n 发帖数: 432 | 5 If you are dealing with large numbers you can use two variables to store
that number. Use a long integer to store the integer part and double for the
fractional part.
For example, if m is an integer for power index
1.12345678901234567890e+m = 1.12345678901234567890*10^(+15)*10^(m-15)
=(1123456789012345.67890)*10^(m-15)
=(1123456789012345 + 0.67890)*10^(m-15)
=(long + double)*10^(m-15)
This way you can keep enough precision in double.
However you have to define your own algorithm for adding, mult
【在 t*****s 的大作中提到】 : 请问有没有什么方法可以定义和使用更长的实数而不使去精度, 比如 : 计算 1。111111111111111112e20 - 1.111111111111111111e20 (小数点后18位) : 多谢帮助
|
k******n 发帖数: 35 | 6 C# can do it. But calling C# from C++ is a little bit tricky. |
l******n 发帖数: 1683 | 7 使用GMP或者类似的库
【在 t*****s 的大作中提到】 : 请问有没有什么方法可以定义和使用更长的实数而不使去精度, 比如 : 计算 1。111111111111111112e20 - 1.111111111111111111e20 (小数点后18位) : 多谢帮助
|