After Rounding to two decimal places, i alwayse get the same value float TestT =round(t*100)/100;   i would like to round it and fix it to two decimal places: 0.009999 -&gt; 0.01
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?
8965
According to the documentation, the  method uses a round-to-even algorithm which is not common for most applications. So I always end up writing a custom function to do the more natural round-half-up algorithm:  public static decimal RoundHalfUp(this decimal d, int decimals) {     if (decimals &lt; 0)     {         throw new ArgumentException("The decimals must be non-negative",              "decimals");     }      decimal multiplier = (decimal)Math.Pow(10, decimals);     decimal number = d * multiplier;      if (decimal.Truncate(number) &lt; number)     {         number += 0.5m;     }     return decimal.Round(number) / multiplier; }   Does anybody know the reason behind this framework design decision?  Is there any built-in implementation of the round-half-up algorithm into the framework? Or maybe some unmanaged Windows API?  It could be misleading for beginners that simply write decimal.Round(2.5m, 0) expecting 3 as a result but getting 2 instead.
109657
First number needs to be rounded to nearest second number. There are many ways of doing this, but whats the best and shortest algorithm? Anyone up for a challenge :-)   1244->1200  1254->1300 123->100 178->200 1576->1600 1449->1400 123456->123500 654321->654300 23->00 83->100
16769
I would like to have the variables (defined in Latex3) aligned in a table with the decimal point. Of course, without using the &quot;trial and error&quot; extra space &quot;,&quot;. Is there any possibility? Thank you very much. \documentclass{article} \usepackage{xparse} \usepackage[version=4]{mhchem}  \usepackage{siunitx,booktabs}  % \ExplSyntaxOn \NewDocumentCommand{\calcnumd}{o m}   {\IfValueTF{#1}      {\num[round-mode = figures, round-precision = #1, round-integer-to-decimal]{\fp_to_decimal:n{#2}}}      {\num{\fp_to_decimal:n{#2}}}   } % data \fp_set:Nn \dhfbiox {33.18} \fp_set:Nn \dhftetrox {9.16} \fp_set:Nn \dgfbiox {51.31} \fp_set:Nn \dgftetrox {97.89} \fp_set:Nn \cpbiox {37.20} \fp_set:Nn \cptetrox {77.28} % calculations % \ExplSyntaxOff % \begin{document}  \begin{center} \begin{tabular}{l|ccc}    &amp; $\Delta_f H^{\ominus}$ &amp; $\Delta_f G^{\ominus}$ &amp; $C_P$ \\    &amp; \si{\kilo\joule\per\mole} &amp; \si{\kilo\joule\per\mole} &amp; \si{\joule\per\kelvin\per\mole} \\ \midrule \ce{NO2} &amp; \calcnumd{\dhfbiox} &amp; \calcnumd{\dgfbiox} &amp; \calcnumd[4]{\cpbiox} \\ \ce{N2O4} &amp; \,\,\,\calcnumd{\dhftetrox} &amp; \calcnumd{\dgftetrox} &amp; \calcnumd{\cptetrox} \\ \bottomrule \end{tabular} \end{center}  \end{document}
67106
Is there a function to round a float in C or do I need to write my own?       float conver = 45.592346543;   I would like to round the actual value to one decimal place, conver = 45.6.
43487
I have a double value f and would like a way to nudge it very slightly larger (or smaller) to get a new value that will be as close as possible to the original but still strictly greater than (or less than) the original.  It doesn't have to be close down to the last bit—it's more important that whatever change I make is guaranteed to produce a different value and not round back to the original.
5370
I was surprised when I heard zero is plural, and even 1.00001 is plural.  Then, what about following numbers ?  (1) 1.00  which means the value measured  between 0.995-1.004, having possibility that it was exactly 1.  (2) 0.99999.....  which is mathematically equal to 1. Also, are others that are mathemattically equal to 1 than this, treated completely same as 1?  (3) -1  Is this singular? Or negative numbers are generally plural?  (4) i = square root of -1  I know it's weird to count things with imaginary numbers, nonetheless, if you were to count, which form, plural or singular, would you be to use?  That's it.
11789
I'd like to convert a float to a whole number in JavaScript. Actually, I'd like to know how to do BOTH of the standard conversions: by truncating and by rounding. And efficiently, not via converting to a string and parsing.
11634
Sorry for asking such a basic question - but is there an actual term for the numbers that appear before and after the decimal point?  Example:  25.18  I know the 1 is in the tenths position, the 8 is in the hundredths position. are there singular terms which apply to all of the numbers that appear both before and after the decimal point?  I'm building a billing system, storing dollars and cents as integers (in separate columns), but for other currencies "dollars" and "cents" are not the correct terms = ).  Thanks!
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.
95377
Firstly I do not want to round my numbers, I am using base 10 figures so excel should have no bother doing simple add and subtract.  A|  665.110000000000000000000000000000 B|  4.990000000000000000000000000000 C|  =a1+b1 D|  670.790000000000000000000000000000 E|  1,335.890000000000000000000000000000 F|  =e1-(c1+d1)   I should get -5 however F1  returns   -4.999999999999770000000000000000   It is a financial document therefore I want to avoid rounding, more to the point. Why should I need to? I've put cell formatting to Currency with 2 decimal placed and I will get the correct display value but for all calculations I will still get -4.9999...7 which leads to further errors with conditional formatting etc.
63306
How can we extract the decimal part of a floating point number and store the decimal part and the integer part into two separate integer variables?
58895
Been trying to this line to parse for a good 20mins, but all attempts have failed:  \beta = $-$0.84, t = $-$2.09, P = 0.04   Could anyone tell me why I'm getting a Missing $ inserted error here?
91240
I realize I posed this question, and got answers, several days ago (see ) , but none seem to really be working, and so am posing again.  Below are two screenshots that show the fields with field properties, and another showing the field calculator and the equation with the "answer" field populated by 0s. I apologize for them not being next to each other or in line with the appropriate text, but the web formatting keeps overlaying them.  Here is an overview of the problem: I am trying to do a in field calculator, where I'm trying to populate a new field with the values from a fairly simple equation of one field divided by another (Cnt1 by Pop1 in this case).  Both fields that I am dividing are double, and the value, while small is not infinitesimal, approx 0.01765.    I have tried creating various types of new fields: double, long, float, and played around with the scale/precision/properties, but everytime it returns "0" values. I know the values will be very small, i.e .04 but it doesn't seem to be a decimal display problem as I tried running it with Pop1/.4 and it correctly returned a decimal.   I've tested dividing the Cnt1 by .5 and that gives an appropriate decimal value, so it's not the new field format; the one thing that seems really strange is when I add (in field calculator python version): !Cnt1!+!Pop1! (which is 38+218699) I get 2.187, however, I suppose this could be related to the field being classified as float with precision=4, scale=3?    I've also tried the suggestions of @blord-castillo of doing:  1.0* (Cnt1/Pop1)   and also      1.0* (int(Cnt1/Pop1)) But neither works, I'm at my wits end on this one, and would greatly appreciate any help!
11931
I need to calculate the SQRT of  $x$ to $y$ decimal places. I'm dealing with $128$-bit precision, giving a limit of $28$ decimal places. Obviously, if $\,y &gt; 28$, the , which I'm currently using, becomes futile, as it simply doesn't offer $y$ decimal places.  My question to you is, can I calculate the Square Root digit-by-digit? For example, calculating the $n$-th digit, assuming I already have digit $\,n - 1$. I'm well aware this may be impossible, as I've not found any such method through Google yet, just checking here before I give up in search of arbitrary precision methods.
24729
I own 2 d10 dice with differently numbered sides (0 through 9, and 00 through 90), although the same applies for two identical 'regular' d10 dice.  How do I read the percentage value if I use both dice?  It's pretty straight-forward if I roll between 11 and 89, but outside this range it becomes slightly confusing:  50, 6 → 56%  8, 9 → 89% 00, 0 → 0% or 10% or 100%? 90, 0 → 90% or 100%? 10, 0 → 10% or 20%?   Note: if I roll with identical d10, I roll sequential, not simultaneous to avoid discussion if the 8 or 9 is the first digit.  I have a hunch that 0% isn't really a thing in most systems that use d100, so that eliminates 00, 0 → 0%.  So is it then true that on the first d10, the 00 counts as zero, but on the second d10, the 0 counts as ten?
40977
Can you round a .NET TimeSpan object?  I have a Timespan value of:  00:00:00.6193789  Is there a simple way to keep it a TimeSpan object but round it to something like 00:00:00.62?