Hello All,
I am using the following to format numbers precise to 2 decimal places
with thousand separators:
Double number = 100000.87;
string MyString = String.Format("{0:0,0.00}", number);
// 100,000.87
which is fine.
When the number is less than zero:
Double number = 0.8756;
string MyString = String.Format("{0:0,0.00}", number);
// 00.87
How do output 0.87 instead of 00.87 ?
Thanks in advance. 3 3890
string MyString = number.ToString("N2");
/claes
"hharry" <pa*********@nyc.comwrote in message
news:e9**********************************@p25g2000 hsf.googlegroups.com...
Hello All,
I am using the following to format numbers precise to 2 decimal places
with thousand separators:
Double number = 100000.87;
string MyString = String.Format("{0:0,0.00}", number);
// 100,000.87
which is fine.
When the number is less than zero:
Double number = 0.8756;
string MyString = String.Format("{0:0,0.00}", number);
// 00.87
How do output 0.87 instead of 00.87 ?
Thanks in advance.
"hharry" <pa*********@nyc.comwrote in message
news:e9**********************************@p25g2000 hsf.googlegroups.com...
Hello All,
I am using the following to format numbers precise to 2 decimal places
with thousand separators:
Double number = 100000.87;
string MyString = String.Format("{0:0,0.00}", number);
// 100,000.87
which is fine.
When the number is less than zero:
Double number = 0.8756;
string MyString = String.Format("{0:0,0.00}", number);
// 00.87
How do output 0.87 instead of 00.87 ?
Thanks in advance.
Would you mind explaining when 0.8756 became less than zero? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Von Shean |
last post by:
I use the following code to format the numbers to have commas. But in case
when input is zero it returns an empty string....any ideas?
String.Format("{0:#,###.##}",dblNum);
|
by: Bob |
last post by:
I'm having trouble the string.Format() throwing exceptions and I can't figure
out what I am doing wrong.
Given the following setup code:
string str = { "one", "two", "three", "four" };
double...
|
by: Akeel |
last post by:
Hi I have the following code
char splitter={','};
string fields=row.ToString().Split(splitter)
string serviceDefintion=""
// row.ToString().Split(splitter
// conatins the followin...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: drtimhill |
last post by:
I'm just starting out on Python, and am stumped by what appears an oddity in the way negative indices are handled.
For example, to get the last character in a string, I can enter "x". To get the...
| |
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first...
|
by: Rick |
last post by:
With String.Format, if I have an incorrect number of args specified for a
format string, compile fails. How can I implement similar design-time
functionality for my own string functions?
|
by: Xah Lee |
last post by:
If i have a nested list, where the atoms are unicode strings, e.g.
# -*- coding: utf-8 -*-
ttt=, ,...]
print ttt
how can i print it without getting the u'\u1234' notation?
i.e. i want it...
|
by: Andrus |
last post by:
How to create format string for decimal data type
which shows blank for zero and default format otherwize ?
I tried format string "f;f;#" but this shows f for nonzero numbers.
Andrus.
...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
| |
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,...
|
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...
|
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,...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |