I have to evaluate a function (3x-2) in a interval [-10,10] with precision increments from 1, 0.1, 0.01, 0.001, 0.0001, etc. I tried this  a=1.0 for x in range(1,40):     for y in range(-10,10,a):         c=3(x)-2         print(c)     a=a/10   (The first for is because I need to get 40 decimals) But I got this error   for x in range(-10,10,a): TypeError: 'float' object cannot be interpreted as an integer   Thanks for the help.
4177
Is there a way to step between 0 and 1 by 0.1?   I thought I could do it like the following, but it failed:  for i in range(0, 1, 0.1):     print i   Instead, it says that the step argument cannot be zero, which I did not expect.
112920
How can I round a decimal number (floating point) to the nearest integer?   e.g.  1.2 = 1 1.7 = 2
115574
I have a range and need to sum it using SUM function but the result is N/A if there is any N/A value. How can I make the SUM function to treat the N/A value as 0 value?  Please help!
99038
Which libraries for Java are there that have a fast implementation for floating point or fixed point operations with a precision of several thousands of digits? How performant are they?  A requirement for me is that it implements a multiplication algorithm that is better than the naive multiplication algorithm that takes 4 times as much time for a 2 times larger number of digits (compare ).
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?
67589
Suppose I have 30 numbers that vary between 0 and 1.0 and which sum to 1.0.  The mean is obviously 0.033.  A client wants these scaled to lie between 0 and 1.0 but to have a mean of 0.5.  By the way, I'll probably have to do this for any set of numbers (positive, negative, outside the range 0 - 1) so that they lie in the range 0 - 1 and have a mean 0.5.  Any suggestions?
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!
113604
I was messing around with my TI-84 Plus Silver Edition calculator and discovered that it will actually give me values when taking the factorial of any number $n/2$ where $n$ is any integer greater than $-2$. Why does this happen? I thought factorials were only defined for positive integers and $0$, so what is my calculator doing to get the answer $3.32335097$ when I enter $2.5!$? Is there actually a definition of $2.5!$ or is my calculator just being weird? How is the factorial function implemented?  I understand the binary implications of $2.5$, so that could possibly have something to do with it. I get a domain error when trying to take the factorial of $-1, 2.3, e$, and any number that is not of the form $n/2$ where $n$ is any integer greater than $-2$.
44860
I am looking to format a number like 188518982.18 to £188,518,982.18 using Python.  How can I do this?
82915
For example, the standard division symbol '/' rounds to zero:  &gt;&gt;&gt; 4 / 100 0   However, I want it to return 0.04. What do I use?
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?
17187
What is the regular expression for a decimal with a precision of 2?  Valid examples:  123.12 2 56754 92929292929292.12 0.21 3.1   Invalid examples:  12.1232 2.23332 e666.76   The decimal point may be optional, and integers may also be included.
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
3799
How do I access the index in a for loop like the following?  ints = [8, 23, 45, 12, 78] for i in ints:     print('item #{} = {}'.format(???, i))   I want to get this output:  item #1 = 8 item #2 = 23 item #3 = 45 item #4 = 12 item #5 = 78   When I loop through it using a for loop, how do I access the loop index, from 1 to 5 in this case?
66729
I want to compare two floating point numbers in a shell script. The following code is not working:  #!/bin/bash    min=12.45 val=10.35     if (( $val &lt; $min )) ; then       min=$val fi echo $min
88482
I need to plot several functions in PGFPlots, and each function I plot is actually the same main function minus the function evaluated at some point x. Instead of hard-coding the value of the function for each x, I was wondering if there's a way to define a function, and then evaluate such function at x. So far the code I have is:  \documentclass{article} \usepackage[usenames,dvipsnames,svgnames,table]{xcolor} \usepackage{amsmath} \usepackage{mathptmx} % Use the Adobe Times Roman as the default text font together with math symbols from the Sym­bol, Chancery and Com­puter Modern fonts  \usepackage{tikz} % Required for drawing custom shapes \usepackage{pgfplots} \usetikzlibrary{plotmarks, calc, spy, pgfplots.polar, external} \usepgflibrary{shapes.geometric}  \begin{document}  % add and edit tikz figure here:  \begin{tikzpicture}[scale=1]     \begin{axis}  \addplot + [mark=none, domain=0:2, samples=70] { (x^0.65 + sin(1.5*pi*x)))/2}; \addplot + [mark=none, domain=0:4, samples=70] { (x^0.65 + sin(1.5*pi*x)) - (2^0.65 + sin(1.5*pi*2))))/2}; \addplot + [mark=none, domain=2:6, samples=70] { (x^0.65 + sin(1.5*pi*x)) - (4^0.65 + sin(1.5*pi*4))))/2}; \addplot + [mark=none, domain=4:8, samples=70] { (x^0.65 + sin(1.5*pi*x)) - (6^0.65 + sin(1.5*pi*6))))/2}; \addplot + [mark=none, domain=6:10, samples=70] { (x^0.65 + sin(1.5*pi*x)) - (8^0.65 + sin(1.5*pi*8))))/2}; \addplot + [mark=none, domain=8:12, samples=70] { (x^0.65 + sin(1.5*pi*x)) - (10^0.65 + sin(1.5*pi*10)))/2}; \addplot + [mark=none, domain=10:13, samples=70] { (x^0.65 + sin(1.5*pi*x)) - (12^0.65 + sin(1.5*pi*12))))/2};      \end{axis} \end{tikzpicture} \end{document}
117815
I have a table with a smallint column that contains percentages as whole numbers (i.e., 50, 75, 85, etc.)  When I divide this column by 100, as in  SELECT MY_COLUMN/100 AS PCT_AS_FRACTION FROM MY_TABLE   the result is rounded to the nearest whole number. For example, for a row that contains the number "50", I get zero as my result.  I can duplicate this with a simple statement:  SELECT 50 / 100 AS TEST_VALUE   Why is that, and how can I get more precision in my result?