473,467 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

NumberFormatInfo.NumberDecimalDigits changes nothing

Hi.

I use a System.Globalization.NumberFormatInfo
(a System.IFormatProvider derival) instance for formatting numbers.

I want to use the NumberDecimalDigits member property to round the numbers
when formatting them as strings. However, this property does not seem to
help me.
For example:
NumberFormatInfo numberFormat = new NumberFormatInfo();

numberFormat.NumberDecimalDigits = 2;

double d = 1.53075794227797E-14;

string s = string.Format(numberFormat, "d = {0}", d);

Console.WriteLine(s);

Shouldn't this example produce a number with two decimals? In this case, it
does not.

It keeps all decimals.

I know i could use a rounding function like Math.Round to manually round the
numbers.

But in some way, it should be possible to use only a NumberFormatInfo
instance to do the job, shouldn't it?

Regards,

Dennis




Nov 15 '05 #1
0 2424

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tom | last post by:
Hi, I have a main program that uses a lot of definitions in different classes. They are included like this: from subclass1 import * from subclass2 import * My problem is: whenever I make...
0
by: Freddy | last post by:
Hi, I am using the following lines of code to format a number according to a culture: //Get the number format according to the user culture. NumberFormatInfo nfi = new CultureInfo(...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
1
by: Dave Wurtz | last post by:
All, I have a NumberFormatInfo object with specific setting (i.e. number of decimals, thousands separator, decimal separator, currency symbols, etc.) based upon my application, not my system's...
1
by: Mythran | last post by:
The NumberDecimalPlaces property is messing me up. I have an arbitrary number, lets say 1234.567. What do I need to do to get the following string: $1 , 234.567...or any decimal value? ...
0
by: Billy | last post by:
Why do I still have to provide a 'String Format' when I have created a NumberFormatInfo object (nfi) that should display what I need. For example I have created a default NumberFormatInfo now when...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
0
by: CrispinH | last post by:
Hi I've just upgraded some Type Editors from 1.1 to 2.0 and whilst they compile OK, I'm not getting any results in the test harness PropertyGrid. Usually when you select a particular property,...
2
by: sparks | last post by:
At first they just wanted to keep a record of who logged in and when. Then it was if they made changes. Now its who changed what. BUT since this made no since to them. WHO put it in and who...
0
marktang
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,...
0
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...
0
Oralloy
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,...
1
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...
0
agi2029
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.