![]() |
![]() |
|
|||||||
| Register | Forum Rules | Getting Started! - Guide | Blog | Videos | Gallery | Members List | Social Groups | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Parsing double precision numbers
After reading the string representation of a double precision number, -0.417597000000000D+06, from a text file, I am unable to convert it to a double precision number. Here is the code I am using: string[] result = block.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); double temp1 = double.Parse(result[0]); After the last statement, I get an unhandled exception. Marathoner |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: Parsing double precision numbers
"marathoner" <rajk2000@msn.com.invalid> wrote in message
news:O3Vy2uRMIHA.4308@TK2MSFTNGP05.phx.gbl... > > > After reading the string representation of a double precision > number, -0.417597000000000D+06, from a text file, I am unable to convert > it to a double precision number. Here is the code I am using: > > string[] result = block.Split(charSeparators, > StringSplitOptions.RemoveEmptyEntries); > double temp1 = double.Parse(result[0]); > > After the last statement, I get an unhandled exception. > > Marathoner > -0.417597000000000D+06 is invalid (the D should be an e or E to be valid), where did you get this from? Willy. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Parsing double precision numbers
marathoner wrote:
> After reading the string representation of a double precision > number, -0.417597000000000D+06, from a text file, I am unable to convert it > to a double precision number. Here is the code I am using: > > string[] result = block.Split(charSeparators, > StringSplitOptions.RemoveEmptyEntries); > double temp1 = double.Parse(result[0]); > > After the last statement, I get an unhandled exception. What is the D in your number? If that is supposed to mean exponent, the correct representation is e (or E). -- Tom Porterfield |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Re: Parsing double precision numbers
Hi,
The D is incorrect, it should be an E. Where are you reading these numbers from? Anyway, use String.Replace double temp1 = double.Parse(result[0].Replace("D","E")); -- Ignacio Machin http://www.laceupsolutions.com Mobile & warehouse Solutions. "marathoner" <rajk2000@msn.com.invalid> wrote in message news:O3Vy2uRMIHA.4308@TK2MSFTNGP05.phx.gbl... > > > After reading the string representation of a double precision > number, -0.417597000000000D+06, from a text file, I am unable to convert > it to a double precision number. Here is the code I am using: > > string[] result = block.Split(charSeparators, > StringSplitOptions.RemoveEmptyEntries); > double temp1 = double.Parse(result[0]); > > After the last statement, I get an unhandled exception. > > Marathoner > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Re: Parsing double precision numbers
"Ignacio Machin ( .NET/ C# MVP )" wrote: > Hi, > > > The D is incorrect, it should be an E. > > Where are you reading these numbers from? > > Anyway, use String.Replace > double temp1 = double.Parse(result[0].Replace("D","E")); > -- > Ignacio Machin > http://www.laceupsolutions.com > Mobile & warehouse Solutions. > "marathoner" <rajk2000@msn.com.invalid> wrote in message > news:O3Vy2uRMIHA.4308@TK2MSFTNGP05.phx.gbl... Looks like an old fortran output... |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Home - Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |