c# - How to convert this scientific notation to decimal? -


after search in google, using below code still can not compiled

decimal h = convert.todecimal("2.09550901805872e-05");    decimal h2 = decimal.parse("2.09550901805872e-05", system.globalization.numberstyles.allowexponent); 

you have add numberstyles.allowdecimalpoint too:

decimal.parse("2.09550901805872e-05", numberstyles.allowexponent | numberstyles.allowdecimalpoint); 

msdn clear that:

indicates numeric string can in exponential notation. allowexponent flag allows parsed string contain exponent begins "e" or "e" character , followed optional positive or negative sign , integer. in other words, parses strings in form nnnexx, nnne+xx, , nnne-xx. it not allow decimal separator or sign in significand or mantissa; allow these elements in string parsed, use allowdecimalpoint , allowleadingsign flags, or use composite style includes these individual flags.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -