c# - How to assign a negative exponent value to double variable? -


d double; f float; d = 4.4e38;//±3.4e38 maximum value of float f = (float)d; console.writeline("f = (float)d " + f);//op infinity d = -2.5e−45;     f = (float)d; console.writeline("f = (float)d " + f);//expected op 0 

my query: d = -2.5e−45;this loc giving compile error, please tell me right way assign value in double variable

edit: yes, right, once corrected minus sign code starts running.;±1.5e−45 minimum value of float. when i'm assigning value -2.5e-45 d, outside lower range, casting double float should have given me result zero, result -2.802597e-45, why?

msdn.microsoft.com/en-us/library/yht2cx7b.aspx in page remarks number 4 states if double big fit float, casting results infinity, , if small results zero. here in code sample i'm trying checking these 2 conditions, taking such values creates case of infinity , 0 after casting. please correct me if have not taken appropriate value of variable d create case zero, outcome.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -