Hi,
I am trying to the following:
String s = "( 54.05)";
decimal d = decimal.Parse(s );
when s = "( 54.05)" I what the value -54.05
and s = " 54.05" I what the value 54.05
Any suggestion.
Thanks. 2 17667
Use the default formatting that Decimal expects, or specify the formatting that you are using:
Decimal.Parse(m yString, System.Globaliz ation.NumberSty les.Currency)
--
Dave Sexton dave@www..jwaon line..com
-----------------------------------------------------------------------
"probashi" <pr******@hotma il.com> wrote in message news:11******** **************@ z14g2000cwz.goo glegroups.com.. . Hi,
I am trying to the following:
String s = "( 54.05)"; decimal d = decimal.Parse(s );
when s = "( 54.05)" I what the value -54.05 and s = " 54.05" I what the value 54.05
Any suggestion.
Thanks.
Than choose the correct style that matches your input from the System.Globaliz ation.NumberSty les enumeration.
If the enumeration does not support your needs, you'll have to parse the string manually. In this case, I suggest using a Regex.
--
Dave Sexton dave@www..jwaon line..com
-----------------------------------------------------------------------
"probashi" <pr******@hotma il.com> wrote in message news:11******** *************@o 13g2000cwo.goog legroups.com... Decimal.Parse(m yString, System.Globaliz ation.NumberSty les.Currency)
is throwing Format Exception. Dave wrote: Use the default formatting that Decimal expects, or specify the formatting that you are using: Decimal.Parse(m yString, System.Globaliz ation.NumberSty les.Currency)
-- Dave Sexton dave@www..jwaon line..com
----------------------------------------------------------------------- "probashi" <pr******@hotma il.com> wrote in message news:11******** **************@ z14g2000cwz.goo glegroups.com.. . > Hi, > > I am trying to the following: > > String s = "( 54.05)"; > decimal d = decimal.Parse(s ); > > > when s = "( 54.05)" I what the value -54.05 > and s = " 54.05" I what the value 54.05 > > > Any suggestion. > > Thanks. >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: gary |
last post by:
I want to pick all intergers and decimal numbers out of a string.
Would this be the most correct regular expression to use?
"\d+\.?\d*"
|
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number. "Decimal Number" sometimes serves to distinguish Base 10
numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal
Number" serves to differentiate a number from an integer. For the rest of this
post I shall only use either...
|
by: Gustaf Liljegren |
last post by:
I searched for previous answers on this, but couldn't find something
fitting. I need advice on how to store decimal numbers with possible
null values in memory. The numbers may be negative, so storing null
values as -1 doesn't work. The numbers are amounts of money, so
decimal is the best datatype, except that it can't store null values.
The best idea so far is to make an object of each number and have it
store either a decimal or null....
|
by: Piotr |
last post by:
Hi
I'm working with Datagrid containg decimal (editable) numbers. The
user-entered numbers are read by decimal.Parse() method. However, Datagrid
formats some decimals as "1", but some as (eg) "1.00" - depends on what the
user had entered. The page has DISABLED viewstate.
So, let someone explain me why the number 1 is not the same as 1.0 or 1.000?
I cannot find any property to set the precision.
|
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
| |
by: Mythran |
last post by:
Dim value As Decimal = 1234.56
Dim format As String = _
"Positive $#,##0.00;Negative $#,##0.00;"
Dim s As String = value.ToString(format)
Dim d As Decimal = Decimal.Parse(s)
The last line above throws an exception because it can't parse "Positive
$1,234.56". It can convert to that format, but how can one go about parsing
it using the same format that was used to format it as a string? Is there
|
by: VK |
last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/
b495b4898808fde0>
is more than one month old - this may pose problem for posting over
some news servers. This is why I'm starting a new one]
I'd still like to finish this rounding mess. As a startup lemma we can
take that VK is the worst programmer of all times and places: let's
move from here forward please.
The usability of any program depends on exact behavior...
|
by: =?Utf-8?B?cGF0cmlja2RyZA==?= |
last post by:
Hi everyone!
I'm using greece - greek in my control panel's regional options,
and so, my decimal point is the comma (,),
while it is the dot (.) for the sql server db,
however, I'm facing trouble when I need to parse the sql server decimal as
an asp.net double!
For example:
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I convert a Number into a String with
exactly 2 decimal places?
-----------------------------------------------------------------------
When formatting money for example, to format 6.57634 to
6.58, 6.5 to 6.50, and 6 to 6.00?
Rounding of x.xx5 is uncertain, as such numbers are not
represented exactly. See section 4.7 for Rounding issues.
|
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: 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: 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: 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: 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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |