I have a a form where a user can make a simple multiplication of two fields. The outcome of the equation is then placed in another input field using jquery.  quantity =         Number($('#quantity').val()); price =            Number($('#price').val());  subtotal = quantity * price;   and  $("input#subtotal").val(subtotal);    But...The numbers do not add up!!   I'm getting very strange answers with long decimals behind the comma. When running my console:  console.log(subtotal, price+ "x" + quantity + "=" + subtotal);       it literally states:  --&gt; 1.07 x 1001 = 1071.0700000000002   What is the best solution here?
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?
64050
I'm trying to use String.Format("{0:c}", somevalue) in C# but am having a hard time figuring out how to configure the output to meet my needs. Here are my needs:   0 outputs to blank 1.00 outputs to $1.00 10.00 outputs to $10.00 100.00 outputs to $100.00 1000.00 outputs to $1,000.00   I've tried String.Format("{0:c}", somevalue) but for zero values it outputs $0.00 which is not what I want. I've also tried String.Format("{0:$0,0.00;$(0,0.00);#}", somevalue), but for 1.0 it outputs $01.00. String.Format("{0:$0.00;$(0.00);#}", somevalue) works for most cases, but when somevalue is 1000.00 the output is $1000.00.   Is there some format that will fit all 5 cases above? All of the documentation I've read only details the basics and doesn't touch on this type of scenario.
16405
In LaTeX2e,how can I sum two values and assign them to other variable?  I want to compute something like:   var=\textwidth - 1cm    And if both were constants:   var=1+1
63628
Here's an example:  Double d = (1/3); System.out.println(d);   This returns 0, not 0.33333... as it should.  Does anyone know?
38898
I need to format a decimal value into a string where I always display at lease 2 decimals and at most 4.   So for example  "34.49596" would be "34.4959"  "49.3" would be "49.30"   Can this be done using the String.format command? Or is there an easier/better way to do this in Java.
96666
I have to design a form with one field being a quantity that represents the number of available items of a given product. I want to allow the user to modify this quantity in 2 different ways, in the same form: they can set directly a new quantity, or they can specify an amount to add/substract to the original quantity.  I thought two input fields could define the operation in the following way: one is for the amount to add/substract, and the other is for the result. If the user modifies one the other gets updated. In the end the value submitted is the value of the "result" input field. Negative numbers are allowed. One quick implementation of this for illustration:    Am I on the right track or is there a common pattern to do this in another way? Maybe it shouldn't be possible to use the 2 modes of operation at the same time, so the user should be able to select from an "exact mode" or a "delta mode"?
45046
I've started a new job and it involves looking at a bunch of big numbers. Is there an easy way to add commas to an int or decimal field to make it readable?  For example, SQL Server outputs the column on the left, but for my own sanity, I need it to look like the one on the right:  2036150 -&gt; 2,036,150     ...or would I have to write some heinous   left(right(vandalized_data),6),3) + ',' + right(left(vandalized_data),6),3)   function?  The perfect thing would be commas in the display grid, then plain integers in the output.
22739
Is this purely personal style, or are the generally accepted guidelines? Clearly, when dealing with numbers either $2 \cdot 2$ or $2 \times 2$ is needed, but within formulae where an absence of an operator implies multiplication, when should a \cdot be used? I tend to use it only sparingly if it aids in grouping. (Of course, barring the cases where it's required, e.g. a dot product.)
7653
public class doublePrecision {     public static void main(String[] args) {          double total = 0;         total += 5.6;         total += 5.8;         System.out.println(total);     } }   The above code prints:  11.399999999999   How would I get this to just print (or be able to use it as) 11.4?
71533
Can I add the comma "," to force the decimals to remove from the attribute and replace with the number?   For example, I have an Acres field column that says 506320.0750 and I want to replace the decimal with the comma, say 506,320? I want that number to be permanment.   Is that possible? I'm using ArcGIS Desktop 9.3.1
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.
103173
I know that it is common to write the number 'ten thousand' as a numeral with a comma delimiting the 10 and the 000 like so: 10, 000  However, I have never seen a comma used for numbers less than 10,000, such as 8000 where, I assume using a comma would look like: 8,000.  Are there any rules relating to when a comma should be inserted into a numeral?  N.b. I live in the UK, so answers pertaining to UK English are preferred.
66844
How do you combine two jQuery search results? eg:  var $allFoos = $('.foo'),     $allBars = $('.bar')     $allFoosAndBars = $allFoos + $allBars;   Obviously, I just made up that last line, but I hope it makes it sorta clear what I mean. To be clear, the example is greatly simplified, and it could be any arbitrary sets i'm talking about, so $('.foo, .bar') is not what I'm after.
44253
Is there a canonical way to typeset such quantities in equations and inline math?  \documentclass{article} \begin{document} $Re$, $Nu$ are clearly not an option. $\mathit{Re}$, $\mathit{Nu}$ appear ok to me. \end{document}
60608
I have the value 25.00 in a float, but when I print it on screen it is 25.0000000. How can I display the value with only two decimal places?
2827
What's the cleanest, most effective way to validate decimal numbers in JavaScript?  Bonus points for:   Clarity. Solution should be clean and simple. Cross-platform.   Test cases:  01. IsNumeric('-1')      =&gt; true 02. IsNumeric('-1.5')    =&gt; true 03. IsNumeric('0')       =&gt; true 04. IsNumeric('0.42')    =&gt; true 05. IsNumeric('.42')     =&gt; true 06. IsNumeric('99,999')  =&gt; false 07. IsNumeric('0x89f')   =&gt; false 08. IsNumeric('#abcdef') =&gt; false 09. IsNumeric('1.2.3')   =&gt; false 10. IsNumeric('')        =&gt; false 11. IsNumeric('blah')    =&gt; false
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.