I need to print all digets of some double number. I have following code:  double number;     while (number != floor (number)) number = number * 10;   But when number = 0.222, I have following result 22200000000000004. How can I avoid this inaccuracy.  P.S. I can use only double, so I can't parse this like a string.
27
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
99240
I write financial applications where I constantly battle the decision to use a double vs using a decimal.  All of my math works on numbers with no more than 5 decimal places and are not larger than ~100,000. I have a feeling that all of these can be represented as doubles anyways without rounding error, but have never been sure.  I would go ahead and make the switch from decimals to doubles for the obvious speed advantage, except that at the end of the day, I still use the ToString method to transmit prices to exchanges, and need to make sure it always outputs the number I expect. (89.99 instead of 89.99000000001)  Questions:   Is the speed advantage really as large as naive tests suggest? (~100 times) Is there a way to guarantee the output from ToString to be what I want? Is this assured by the fact that my number is always representable?   UPDATE: I have to process ~ 10 billion price updates before my app can run, and I have implemented with decimal right now for the obvious protective reasons, but it takes ~3 hours just to turn on, doubles would dramatically reduce my turn on time. Is there a safe way to do it with doubles?
26607
Is the concept of even/odd numbers applicable to decimal numbers? For e.g. - 4.222 is a even number?
85087
How can I show double numbers (for example iii, 5/229) as in this  book
44860
I am looking to format a number like 188518982.18 to £188,518,982.18 using Python.  How can I do this?
79818
This is probably pretty basic, but to save me an hour or so of grief can anyone tell me how you can work out the number of bits required to represent a given positive integer in Java?  e.g. I get a decimal 11, (1011). I need to get the answer, 4.  I figured if I could work out how to set all the bits other than the most significant bit to 0, and then >>> it, I'd get my answer. But... I can't.
6418
In my  I was printing a double using cout that got rounded when I wasn't expecting it.  How can I make cout print a double using full precision?
31758
The documentation for the  function states that you pass it a number, and the positions past the decimal to round. Thus it should do this:  n = 5.59 round(n, 1) # 5.6   But, in actuality, good old floating point weirdness creeps in and you get:  5.5999999999999996   For the purposes of UI, I need to display 5.6. I poked around the Internet and found some  that this is dependent on my implementation of Python. Unfortunately, this occurs on both my Windows dev machine and each Linux server I've tried. .  Short of creating my own round library, is there any way around this?
41282
Here's my code:  x = 1.0 y = 100000.0     print x/y   My quotient displays as 1.00000e-05.  Is there any way to suppress scientific notation and make it display as 0.00001? I'm going to use the result as a string.
115153
I know you can't rely on equality between double or decimal type values normally, but I'm wondering if 0 is a special case.  While I can understand imprecisions between 0.00000000000001 and 0.00000000000002, 0 itself seems pretty hard to mess up since it's just nothing.  If you're imprecise on nothing, it's not nothing anymore.  But I don't know much about this topic so it's not for me to say.  double x = 0.0; return (x == 0.0) ? true : false;   Will that always return true?
21336
I am trying to group numbers based on the count of digits in the square they produce, and below is the list containing the grouping that I've done so far.  1 - 3     // Numbers producing 1 digit when squared ... 4 - 9     // Numbers producing 2 digits ... 10 - 31   // Numbers producing 3 digits ... 32 - 99   // and so on ... 100 - 316   317 - 999   1000 - 3162 3163 - 9999 10000 - 31622 31623 - 99999 100000 - 316227 316228 - 999999   As one can observe, every range that produces odd digit count has a lower bound of $10^{i-1}$, while its upper bound has an observable pattern. I want to know if this can be represented by a formula or if the upper bound is a known constant such that we can use it as $C \cdot 10^{i-1}$.
2900
It's supposed to be zero but for some reason the result produces a peculiar series of digits at the end.  Also, here's the .xlsx of it: http://83.212.111.36/Book1.xlsx
8712
I read recently that you can find the number of digits in a number through the formula $\lfloor \log_{10} n \rfloor +1$ What's the logic behind this rather what's the proof?
2266
In follow up to , it appears that some numbers cannot be represented by floating point at all, and instead are approximated.  How are floating point numbers stored?  Is there a common standard for the different sizes?  What kind of gotchas do I need to watch out for if I use floating point?  Are they cross-language compatible (ie, what conversions do I need to deal with to send a floating point number from a python program to a C program over TCP/IP)?
16695
To use  as you would require when using the  with large numbers (100,000+), it calls for some very large calculations.  When I multiply two large numbers (eg: 62574 and 62574) PHP seems to cast the result to a float. Getting the modulus value of that returns strange values.  $x = 62574 * 62574; var_dump($x);          // float(3915505476) ... correct var_dump($x % 104659); // int(-72945)  ... wtf.   Is there any way to make PHP perform these calculations properly? Alternatively, is there another method for finding modulus values that would work for large numbers?
70051
How can I format Floats in Java so that the float component is displayed only if it's not zero? For example:   123.45 -> 123.45 99.0   -> 99 23.2   -> 23.2 45.0   -> 45   Edit: I forgot to mention - I'm still on Java 1.4 - sorry!
53630
If I run this code:  select 99999 * 9999   result = 999890001  If I run this code:  select 9999923 * 99999999   result:     Msg 8115, Level 16, State 2, Line 1   Arithmetic overflow error converting expression to data type int.   And If I run the following code:  select 922337299987987689745893 * 999999994564   result = 922337294974162127011191918541325652  Why am I getting this arithmetic overflow error within a specific range?