473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HOWTO: Convert a string in scientific format to a decimal

Hi,

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

Convert.ToDecim al("1283912839 E-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 NumberFormatInf o, but dont know how to use the format
specifiers in the NumberFormatInf o.

Thanks in advance.


Jul 21 '05 #1
2 2142
string x = "1283912839 E-5";
decimal dec = Decimal.Parse( x, NumberStyles.Al lowExponent );

Chris R.

"Krish" <kr********@hot mail.com> wrote in message
news:en******** ******@TK2MSFTN GP11.phx.gbl...
Hi,

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

Convert.ToDecim al("1283912839 E-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 NumberFormatInf o, but dont know how to use the format specifiers in the NumberFormatInf o.

Thanks in advance.

Jul 21 '05 #2
Thanks a lot!!

"Chris R" <so*****@hotmai l.com> wrote in message
news:eT******** ******@tk2msftn gp13.phx.gbl...
string x = "1283912839 E-5";
decimal dec = Decimal.Parse( x, NumberStyles.Al lowExponent );

Chris R.

"Krish" <kr********@hot mail.com> wrote in message
news:en******** ******@TK2MSFTN GP11.phx.gbl...
Hi,

How to convert "1283912839 E-5" string (in scientific format) to a decimal.
Convert.ToDecim al("1283912839 E-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 NumberFormatInf o, but dont know how to use the

format
specifiers in the NumberFormatInf o.

Thanks in advance.


Jul 21 '05 #3

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

Similar topics

1
8813
by: Nick | last post by:
Well, the project I am working on has now come to a screeching halt! I have been developing a program that heavily utilizes ADO.NET record sets. To generate reports, I convert the recordset to XML, and then apply an XSLT to transform the XML into HTML. This works great (or did) until today. I just found out that the "number-format" command in...
4
9720
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a numeric value according to an arbitrary regular expression.
4
17838
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 exponential format not supported during conversion? I think we need to use NumberFormatInfo, but dont know how to use the format specifiers in the...
1
8915
by: Ed S | last post by:
I'm trying to format a double with this behavior: 1) should only show 8 characters (character count before and after decimal added together). 2) if greater than 7 characters to the left of the decimal, should display in scientific notation. 3) if 7 characters or less to the left of the decimal, should round the characters to the right of...
2
10582
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 like $2,295.99. For each row I need to do some additional calculations based on this value, so I need to convert it back to decimal type. But I...
3
12892
by: JenHu | last post by:
Hi all, I have to read from a text file and generate values and insert to database. But first of all, when the text file contains '0000000000', I received a sEfundAmt value = 0D instead of 0.0 on sEfundAmt = Decimal.Parse(Mid$(sRetLine, 30, 10)) / 100.0 For example, in the text file, value is '0000150776', I want to
5
2309
by: AMP | last post by:
Hello, I want to add some variables to a string and this isnt working. textBox1.Text="'BSL version='+ bslVerHi+ bslVerLo"; What am I doing wrong? Thanks Mike
1
27599
by: dmitri | last post by:
I am importing a bunch of data which is all in varchar format which I cast into the relevant type on transfer to the production table. One of these columns contains decimals, but some of them are occasionally given in scientific notation (3.48E-02). I am using CAST (v1 AS decimal(18, 13)) to do the conversion, but that seems to be unable...
10
4933
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
0
7695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.