After reading the string representation of a double precision
number, -0.4175970000000 00D+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(cha rSeparators,
StringSplitOpti ons.RemoveEmpty Entries);
double temp1 = double.Parse(re sult[0]);
After the last statement, I get an unhandled exception.
Marathoner 4 3953
"marathoner " <ra******@msn.c om.invalidwrote in message
news:O3******** ******@TK2MSFTN GP05.phx.gbl...
>
After reading the string representation of a double precision
number, -0.4175970000000 00D+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(cha rSeparators,
StringSplitOpti ons.RemoveEmpty Entries);
double temp1 = double.Parse(re sult[0]);
After the last statement, I get an unhandled exception.
Marathoner
-0.4175970000000 00D+06 is invalid (the D should be an e or E to be valid),
where did you get this from?
Willy.
marathoner wrote:
After reading the string representation of a double precision
number, -0.4175970000000 00D+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(cha rSeparators,
StringSplitOpti ons.RemoveEmpty Entries);
double temp1 = double.Parse(re sult[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
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(re sult[0].Replace("D","E "));
--
Ignacio Machin http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"marathoner " <ra******@msn.c om.invalidwrote in message
news:O3******** ******@TK2MSFTN GP05.phx.gbl...
>
After reading the string representation of a double precision
number, -0.4175970000000 00D+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(cha rSeparators,
StringSplitOpti ons.RemoveEmpty Entries);
double temp1 = double.Parse(re sult[0]);
After the last statement, I get an unhandled exception.
Marathoner
"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(re sult[0].Replace("D","E "));
--
Ignacio Machin http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"marathoner " <ra******@msn.c om.invalidwrote in message
news:O3******** ******@TK2MSFTN GP05.phx.gbl...
Looks like an old fortran output... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BGP |
last post by:
I am working on a WIN32 API app using devc++4992 that will accept Dow
Jones/NASDAQ/etc. stock prices as input, parse them, and do things with
it. The user can just cut and paste back prices into a window and hit
a button to process it.
The information thus enters the program as a char array. Prices can be
between $1 and $100, including cents. So we can have prices such as
3.01, 1.56, 11.57, etc. The char array is an alphanumeric...
|
by: DAVID SCHULMAN |
last post by:
I've been trying to perform a calculation that has been running into
an underflow (insufficient precision) problem in Microsoft Excel, which
calculates using at most 15 significant digits. For this purpose, that
isn't enough.
I was reading a book about some of the financial scandals of the
1990s called "Inventing Money: The Story of Long-Term Capital Management
and the Legends Behind it" by Nicholas Dunbar. On page 95, he mentions
that...
|
by: Madan |
last post by:
Hi all,
I had problem regarding float/double arithmetic only with + and -
operations, which gives inaccurate precisions. I would like to know how the
arithmetic operations are internally handled by C# or they are hardware
(processor) dependent. Basic addition operation errors, for ex:
3.6 - 2.4 = 1.19999999999 or 1.20000000003
There are the erroneous values I'm getting. I'm using C#.Net v1.1 Please
reply me how these operations are...
|
by: lcw1964 |
last post by:
This may be in the category of bush-league rudimentary, but I am quite
perplexed on this and diligent Googling has not provided me with a
clear straight answer--perhaps I don't know how to ask the quesion.
I have begun to familiarize myself here with the gcc compiler in a
win32 environment, in the form of MinGW using both Dev C++ and MSYS as
interfaces.
I have recompiled some old math code that uses long double types
throughout and...
|
by: Ole Nielsby |
last post by:
First, sorry if this is off-topic, not strictly being a C++ issue.
I could not find a ng on numerics or serialization and I figure
this ng is the closest I can get.
Now the question:
I want to serialize doubles in human-readable decimal form
and be sure I get the exact same binary values when I read
them back. (Right now, I don't care about NaN, infinities etc.)
| |
by: Alexander Stoyakin |
last post by:
Hello,
please advise on the following issue. I need to check that difference
between two double values is not higher than defined limit.
int main()
{
double limit = 0.3;
double val1 = 0.5, val2 = 0.2;
if ( (val1 - val2) limit )
|
by: Virtual_X |
last post by:
As in IEEE754
double consist of
sign bit
11 bits for exponent
52 bits for fraction
i write this code to print double parts as it explained in ieee754
i want to know if the code contain any bug , i am still c++ beginner
|
by: md |
last post by:
Hi
Does any body know, how to round a double value with a specific number
of digits after the decimal points?
A function like this:
RoundMyDouble (double &value, short numberOfPrecisions)
It then updates the value with numberOfPrecisions after the decimal
|
by: James Harris |
last post by:
I'm trying to make sense of the standard C data sizes for floating
point numbers. I guess the standards were written to accommodate some
particular floating point engines that were popular at one time but I
can only find references to the number of decimals etc. Basically, if
I wanted to specify C-sized reals in a language that only accepted bit-
widths, e.g.
float(exponent 8, mantissa 24)
I'm looking for what numbers would be needed...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |