如何存储一个非常小的数字 [英] how to store a very small number

查看:69
本文介绍了如何存储一个非常小的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。



我有一个公式来计算C#中某些数字的权重。我有9个砝码。这些权重之和为1.因此,这些权重太小。

例如在计算这些权重后,结果如下:

1 / 17,1 / 17,1 / 17,1 / 17,1 / 17, 1 / 17,1 / 17,1 / 17,9 / 17

当我想将这些权重存储在双重类型的参数中时,存储的值将是:

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0

问题是我需要在另一个公式中使用这些权重的确切值,它们太重要了那个公式。它们的总和应该是1.

我可以做些什么来解决这个问题?请帮帮我。





非常感谢。

Hello.

I have a formula to calculate weights of some numbers in C#. I have 9 weights. Sum of these weights are 1. So,These are too small.
For instance after calculating these weights, the result is something like below:
1/17 , 1/17 ,1/17 ,1/17 ,1/17 ,1/17 ,1/17 ,1/17 ,9/17
When I want to store these weights in a parameter with double type, the stored values will be:
0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0
The problem is that I need the exact value of these weights to use in another formula, and they are too important in that formula. Sum of them should be 1.
What can I do for solving this problem? Please help me.


Thanks a lot.

推荐答案

float double 类型将轻松保存上述值,请参阅 http://msdn.microsoft.com/en-us/library/678hzkk9.aspx [ ^ ]对于 double 可以持有。
The float or double types will easily hold values such as the above, see http://msdn.microsoft.com/en-us/library/678hzkk9.aspx[^] for the range that a double can hold.


这篇关于如何存储一个非常小的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆