Scientific Notation in C #

How to assign a number that is in scientific notation for a variable in C #?

I am looking to use Plancks Constant which is 6.626 X 10 -34

This is the code that I have is incorrect:

Decimal PlancksConstant = 6.626 * 10e-34; 
+6
source share
2 answers

You should be able to declare PlancksConstant as double and multiply 6.626 by 10e-34, for example:

 double PlancksConstant = 6.626e-34 

Demo

+6
source

You can set it like this (note the M suffix for the decimal type):

 decimal PlancksConstant = 6.626E-34M; 

But it will be effectively 0 , because you cannot imagine a number with a value less than 1E-28 as decimal .

So you need to use double instead and just define this:

 double PlancksConstant = 6.626E-34; 
+8
source

Source: https://habr.com/ru/post/1014295/


All Articles