[英]Scientific Notation in C#
How do I assign a number that is in scientific notation to a variable in C#? 如何将科学记数法中的数字分配给C#中的变量?
I'm looking to use Plancks Constant which is 6.626 X 10 -34 我想使用Plancks Constant,即6.626 X 10 -34
This is the code I have which isn't correct: 这是我的代码,这是不正确的:
Decimal PlancksConstant = 6.626 * 10e-34;
You can set it like this (note the M
suffix for the decimal
type): 你可以像这样设置它(注意
decimal
类型的M
后缀):
decimal PlancksConstant = 6.626E-34M;
But this will effectively be 0 because you can't represent a number with magnitude less than 1E-28 as a decimal
. 但这实际上是0,因为你不能用
decimal
表示幅度小于1E-28的decimal
。
So you need to use double
instead and can just define this: 所以你需要使用
double
而不是定义它:
double PlancksConstant = 6.626E-34;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.