473,395 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

HOWTO: Convert a string in scientific format to a decimal

Hi,

How to convert "1283912839E-5" string (in scientific format) to a decimal.

Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in
correct format" exception. Is the exponential format not supported during
conversion?

I think we need to use NumberFormatInfo, but dont know how to use the format
specifiers in the NumberFormatInfo.

Thanks in advance.


Nov 15 '05 #1
4 17830
string x = "1283912839E-5";
decimal dec = Decimal.Parse( x, NumberStyles.AllowExponent );

Chris R.

"Krish" <kr********@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi,

How to convert "1283912839E-5" string (in scientific format) to a decimal.

Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in
correct format" exception. Is the exponential format not supported during
conversion?

I think we need to use NumberFormatInfo, but dont know how to use the format specifiers in the NumberFormatInfo.

Thanks in advance.

Nov 15 '05 #2
string x = "1283912839E-5";
decimal dec = Decimal.Parse( x, NumberStyles.AllowExponent );

Chris R.

"Krish" <kr********@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi,

How to convert "1283912839E-5" string (in scientific format) to a decimal.

Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in
correct format" exception. Is the exponential format not supported during
conversion?

I think we need to use NumberFormatInfo, but dont know how to use the format specifiers in the NumberFormatInfo.

Thanks in advance.

Nov 15 '05 #3
Thanks a lot!!

"Chris R" <so*****@hotmail.com> wrote in message
news:eT**************@tk2msftngp13.phx.gbl...
string x = "1283912839E-5";
decimal dec = Decimal.Parse( x, NumberStyles.AllowExponent );

Chris R.

"Krish" <kr********@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi,

How to convert "1283912839E-5" string (in scientific format) to a decimal.
Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in
correct format" exception. Is the exponential format not supported during conversion?

I think we need to use NumberFormatInfo, but dont know how to use the

format
specifiers in the NumberFormatInfo.

Thanks in advance.


Nov 15 '05 #4
Thanks a lot!!

"Chris R" <so*****@hotmail.com> wrote in message
news:eT**************@tk2msftngp13.phx.gbl...
string x = "1283912839E-5";
decimal dec = Decimal.Parse( x, NumberStyles.AllowExponent );

Chris R.

"Krish" <kr********@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi,

How to convert "1283912839E-5" string (in scientific format) to a decimal.
Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in
correct format" exception. Is the exponential format not supported during conversion?

I think we need to use NumberFormatInfo, but dont know how to use the

format
specifiers in the NumberFormatInfo.

Thanks in advance.


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Krish | last post by:
Hi, How to convert "1283912839E-5" string (in scientific format) to a decimal. Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in correct format" exception. Is the...
3
by: Harry Keck | last post by:
I would imagine that this is a pretty trivial operation, but I can not figure out how to cast a string variable to a Decimal. I tried Decimal dVariable = (Decimal)strStringVariable, but it does not...
2
by: KB | last post by:
Hi guys, In my DataGrid I have a column that displays decimal values as currency ( I set the Data Formatting expression of that column to {0:C}). So the actual string displayed in the grid looks...
0
by: Martyn Fewtrell | last post by:
Hi there I'm sure there is a straight forward answer to this but I haven't quite got there. If I have a String in Sterling Currency Format and try to convert this to a Decimal (for arithmetic...
3
by: dermot | last post by:
None of the Converter tyeps (eg ASCIIEncoding )let you convert between string and 8-bit bytes (0-255). It took me a long time to find there is a way, well, at least 2 ways.....here is the way to...
15
by: shiniskumar | last post by:
How to convert string to double? Ive got a double variable dTot; its value is 5.037717235E7 when i did FreemarkerTools.formatDecimal(dTot) i got it as string "50377172.35". now i want to...
4
by: sweatha | last post by:
Hi In sql server 2005 I have a column as GraduationYear Decimal(4,0). In asp.net I used the coding for that as SqlParameter GraduationYear = new SqlParameter("@GraduationYear",...
8
code green
by: code green | last post by:
I am being sent a CSV file with ID numbers somehow converted to scientific format ie 1.93E+11 and 3.70E+9. In theory the same thing could happen to telephone numbers or even currency. I am trying...
1
by: lenora | last post by:
How to convert string to decimal ? input - output 45 - 45.00 45.5 - 45.50 45.51 - 45.51 Thank you in advance
3
by: tanishka singh | last post by:
How do you convert string from database into date in asp.net? Dim output = (From tlb In obj.SelectRecordAll_SalesInquiryRegister _ Join tlb1 In LatestPOs On tlb.SIR_OfferNo...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.