When i try it like you say, he ignores the dot.
For example
s = "12.45";
d = double.Parse(s) ;
d will be 1245.0 :(
pls help 2 2117
On Fri, 06 Jul 2007 01:48:13 -0700, <Ni************ ****@googlemail .com
wrote:
When i try it like you say, he ignores the dot.
For example
s = "12.45";
d = double.Parse(s) ;
d will be 1245.0 :(
What are your culture settings? Clearly, parsing "12.45" as a double
would normally work in the context of a US-configured computer. I will
hazard a guess that you're using the comma for the decimal separator, and
the period for the thousands separator. If that's the case, then you need
to parse "12,45" if you expect to have a value returned that is twelve and
forty-five hundredths.
There are overloads for the Parse() method that take culture-specific
format providers, so if you know the string is from a specific culture
that may be different from what the user has configured, you can use those
to ensure correct conversion.
Pete
<Ni************ ****@googlemail .comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.com.. .
When i try it like you say, he ignores the dot.
For example
s = "12.45";
d = double.Parse(s) ;
d will be 1245.0 :(
This is because the default Culture that you are using defines de dot as
a thousands separator instead of a decimal point. You can either write your
string with a comma for the decimal point ("12,45"), or change the
CurrentCulture, or change the FormatProvider of the Parse method:
using System.Globaliz ation;
....
CultureInfo ci = new CultureInfo("en-US");
....
s = "12.45";
d = double.Parse(s, ci); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cindy liu |
last post by:
Hi,
In .Net, how to convert a string to a double?
Thanks in advance!
Cindy
|
by: Lyle Fairfield |
last post by:
d1 and d2 are numbers we can store as doubles (8 bytes).
d1 > 0
d2 > 0
d1 < d2
Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode here).
Into s1 and s2 we copy the 8 bytes from d1 and d2 respectively.
|
by: Pascal |
last post by:
Why does this not work, and how should i do this convert in stead:
string x = double.MinValue.ToString();
double y = Convert.ToDouble(x);
i get this exception:
An unhandled exception of type 'System.OverflowException' occurred in mscorlib.dll
Additional information: Value was either too large or too small for a Double.
Pascal
|
by: paul gao via .NET 247 |
last post by:
hi all.
In my program I need to convert a double number to stringrepresentation in fraction format and vise versa. For example,convert 0.75 to string "3/4" and convert string "1/2" to 0.5.The class will only need to handle numbers that increment by1/32. That is 1/32, 2/32, 3/32.... 31/32, 1. If the doublenumber is 0.28 which is between 1/4 and 9/32, the string shouldbe 9/32(go with the bigger number).
TIA
--------------------------------...
|
by: David Scemama |
last post by:
Hi,
I'm writing a program using VB.NET that needs to communicate with a DOS
Pascal program than cannot be modified. The communication channel is through
some file databases, and I have a huge problem writing VB Double values to
the file so as the Pascal program can read them as Pascal Real values.
I've managed to find the algorithm to read the Pascal Real format and
convert it to a VB Double, but I cannot figure out the opposite...
| |
by: Edwin Knoppert |
last post by:
In my code i use the text from a textbox and convert it to a double value.
I was using Convert.ToDouble() but i'm used to convert comma to dot.
This way i can assure the text is correct.
However it seems this convert is determined by the local settings and comma
is indeed used as decimal separator.
Is there another way to convert a dotted value to a double variable?
Like 1234.5 and not 1234,5
|
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: kanepart2 |
last post by:
Hi guys, I am having a problem with the following code snippet:-
double x = (myReader);
double y = (myReader);
Resulting in the follwing compilation error:
Cannot implicitly convert type 'object' to 'double'. An explicit
conversion exists (are you missing a cast?)
|
by: Evyn |
last post by:
Hi all,
I have recently asked for advice:
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/1b42e6855a2c571b/e63d8f10b51f015c?lnk=raot#e63d8f10b51f015c
My task is to convert a string of characters to a double. The string
is read from a file and will be in the format 12345. The double output
must be 0.12345.
My answer to this problem was:
|
by: Bjorn Brox |
last post by:
Hi!
In germany, norway and France(?) we are using ',' as decimal separator
and it always messes up when you convert a double to and from a string
where the interface expects double values stored as string is using '.'
What parameter shall I use in double.ToString() to ensure that the
outputstring always are using '.' as separator without thousand sep,
and what parameter shall I use to convert double to Double.Parse() or...
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
| |