Your question is meaningless. Doubles don't have "places after the decimal" in the first place. They don't store anything that looks remotely like a "decimal representation of a number" internally.
In fact, they don't store anything internally that even looks like recognizable text.
Up vote 1 down vote favorite share g+ share fb share tw.
When using double. Parse, it seems to like to string away any trailing (insignificant) zeros from the string that I'm converting. I would like double.
Parse to keep to places after the decimal. For example, here is some code: tobereturned. MouseSensitivty = double.
Parse(String. Format("{0:#. ##}", tempstring1)); Debug.
WriteLine("Converted " + String. Format("{0:#. ##}", tempstring1) + " to " + tobereturned.
MouseSensitivty); The Debugger then writes Converted 4.00 to 4 So it seems like double. Parse is doing something fishy here. P.S. MouseSensitivity is also of the type double, so I can't do any string operations on it.
C# double significant-digits link|improve this question edited Apr 22 '11 at 22:04Jonathan Leffler139k10108268 asked Dec 11 '10 at 6:49TGP19948111 64% accept rate.
I don't thing that double. Parse is doing anything odd/fishy. The Number.FormatDouble() function is probably what is rendering your number without the decimal places.
(the function that Double.ToString() calls. ) – jwwishart Dec 11 '10 at 7:08.
Your question is meaningless. Doubles don't have "places after the decimal" in the first place. They don't store anything that looks remotely like a "decimal representation of a number" internally.
In fact, they don't store anything internally that even looks like recognizable text. It reports 4 because 4.00 is exactly equal to 4. It is displaying the number "exactly four with no fractional part" as text according to its default rules for converting numbers to text.
Please read this. Yes, it is long, and difficult, but it is simply not possible to use floating-point numeric types properly without a real understanding of this material - and it doesn't matter what language you're using, either.
Thank you for explaining that to me. I can understand why it wants to cut off any insignificant figures, although I'm having trouble understanding what you mean when you say "Doubles don't have 'places after the decimal' in the first place". According to msdn.microsoft.com/en-us/library/… , it seems they do :\ – TGP1994 Dec 11 '10 at 15:56 1 To have "places after the decimal", the number would have to be represented in decimal (i.e.
Base 10). It is not. It is represented in binary (i.e.
Base 2). – Karl Knechtel Dec 11 '10 at 16:08 If that was the case, then wouldn't we never be able to have a larger number than a base 2 number? I mean, yes, I know it has to be stored in the memory of the computer at some point (in binary form), but, doesn't the compiler take measures to ensure that the number is the same once it is read out of the memory again?
– TGP1994 Dec 11 '10 at 16:12 "Larger number than a base 2 number" is meaningless. The base in which you represent a number does not, itself, limit the range of possible numbers; it also depends how many digits/bits you use. The compiler doesn't need to take any such measures.
The number is the number - which is not the same thing as its representation in text. When the number is read in, there is a conversion from text to the internal numeric format; and when the number is displayed, there is a conversion back to text. These conversions do not cancel each other out and there is no reason in general to expect them to.
– Karl Knechtel Dec 11 '10 at 16:18.
The double data type is simply a number; it doesn't keep track of the string that was parsed to create the value. Its string representation only comes into play when .ToString() is called.
If you know you always want two places after the decimal you can right-fill with zeros. It is not the job of the double type to keep track of your desired display format.
With String. Format? – TGP1994 Dec 11 '10 at 15:57 sure you could do that – BitOff Dec 11 '10 at 19:00.
Double does not store redundant zeros. In your view or presentation layer, you might want to format it to show you want it to appear, e.g. , String. Format("{0:#.
##}", doubleVariable).
– TGP1994 Dec 11 '10 at 15:58 nopers, just turn on html switch and use formating {0:F2} in the mark up – Carnotaurus Dec 12 '10 at 12:23.
Well, after all of this, I think having those extra two zeros show up is a little bit too much. I'll add a note in my PropertyGrid description box saying that the number does does support values up to the nearest hundredth. Thanks again, everyone.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.