In console, of any web page, I do:  console.log(11111111111111111);  The result is: 11111111111111112  So I am really confused, trying to add 1s and see what happens:   111111111111111111 -> 111111111111111100 1111111111111111111 -> 1111111111111111200 11111111111111111111 -> 11111111111111110000 111111111111111111111 -> 111111111111111110000   Am I going crazy? What causes this to happen?  Is this intended? Is this a bug with Javascript?    Note: I am pretty sure it is not an integer overflow or something, because adding one 1 more goes to 1.1111111111111111e+21 which is correct.    This question differs from , because I am not asking about the limit of numbers that can be represented accurately, I am asking more like:  Why 11111111111111111 -> 11111111111111112 instead of 11111111111111111 -> 1.1111111111111111e+16 (scientific notation)
1072
Is this defined by the language? Is there a defined maximum? Is it different in different browsers?
89905
For example, when I divided $1$ by $98$, I got an amazing result of $0.0102040816326530612244897...$ where so many numbers get multiplied by two every time in the right pattern with some carrying.  Also, when I divided $1$ by $998$, I got an amazing result of $0.0010020040080160320641282...$.  I have a longer result from my cool memory, which is $0.001002004008016032064128256513026052104208517034068136272545090180360721442885...$What explains why this doubling thing is happening?  I love it when I see it!  Also I don't know if it repeats (I'm talking about 1/998).  I think it does because I looked it up and it said 498 numbers repeat every time, so it's rational.  I mean seriously, how does this doubling happen?  I hope I can receive good information from you!
42119
Consider any integer, suppose a number 3. We can break any such integer down into a sequence of 1's. So, we can write: $$ 3\equiv1+1+1 $$ 3 represents what we get when we add 1 to 1 to another 1. Conceptually, what I am getting confused with, is the fact that notionally, at least according to this definition, there is one unit at the beginning, to which we add another, and yet a third. There seems to be a sequence here, which would imply there being an order. Am I missing something obvious?
68475
I have a a string in c# initialised as follows:  string strVal = "£2000";   However whenever I write this string out the following is written:  Â£2000  It does not do this with dollars.  An example bit of code I am using to write out the value:  System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("/logging.txt"), strVal);   I'm guessing it's something to do with localization but if c# strings are just unicode surely this should just work?  CLARIFICATION: Just a bit more info, Jon Skeet's answer is correct, however I also get the issue when I URLEncode the string. Is there a way of preventing this?  So the URL encoded string looks like this:  "%c2%a32000"  %c2 = Â %a3 = £  If I encode as ASCII the £ comes out as ?  Any more ideas?
4164
Using echo "20+5" literally produces the text "20+5".  What command can I use to get the numeric sum, 25 in this case?  Also, what's the easiest way to do it just using bash for floating point? For example, echo $((3224/3807.0)) prints 0 :(.  I am looking for answers using either the basic command shell ('command line') itself or through using languages that are available from the command line.
90864
I very rarely meet any other programmers!  My thought when I first saw the token was "implies that" since that's what it would read it as in a mathematical proof but that clearly isn't its sense.  So how do I say or read "=>" as in:-  IEnumerable&lt;Person&gt; Adults = people.Where(p =&gt; p.Age &gt; 16)   Or is there even an agreed way of saying it?
9588
I was writing a program in C++ to find all solutions of ab = c, where a, b and c together use all the digits 0-9 exactly once. The program looped over values of a and b, and it ran a digit-counting routine each time on a, b and ab to check if the digits condition was satisfied.  However, spurious solutions can be generated when ab overflows the integer limit. I ended up checking for this using code like:  unsigned long b, c, c_test; ... c_test=c*b;         // Possible overflow if (c_test/b != c) {/* There has been an overflow*/} else c=c_test;      // No overflow   Is there a better way of testing for overflow? I know that some chips have an internal flag that is set when overflow occurs, but I've never seen it accessed through C or C++.    Beware that signed int overflow is undefined behaviour in C and C++, and thus you have to detect it without actually causing it. For signed int overflow before addition, see .
99569
Is there a way to write binary literals in C#, like prefixing hexadecimal with 0x? 0b doesn't work.  If not, what is an easy way to do it? Some kind of string conversion?
5691
Is there a better way of getting this result? This function fails if num has more digits than digits, and I feel like it should be in the library somewhere (like Integer.toString(x,"%3d") or something)  static String intToString(int num, int digits) {     StringBuffer s = new StringBuffer(digits);     int zeroes = digits - (int) (Math.log(num) / Math.log(10)) - 1;      for (int i = 0; i &lt; zeroes; i++) {         s.append(0);     }     return s.append(num).toString(); }
1339
console.log(&quot;double&quot;); vs. console.log('single'); I see more and more JavaScript libraries out there using single quotes when handling strings. What are the reasons to use one over the other? I thought they're pretty much interchangeable.
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?
82601
I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform such an operation?
55075
I saw a post on  which links to a video where a person . Is he saying a large portion of the numbers wrong? Back in high school my algebra teacher was extremely picky.  If we were going to say the number 135, we would say one hundred thirty-five.  If a person said one hundred and thirty-five my teacher would interpret that to mean 100.35.  Was my algebra teacher wrong, or did Jon just waste over 80 hours counting to 100,000 incorrectly. I tried searching the web, but searching for ‘numbers and’  doesn’t work very well.  Can you point me to a reference or style guide that describes how to properly say large numbers?
48880
In my understanding of Cantor's diagonal argument, we start by representing each of a set of real numbers as an infinite bit string.  My question is: why can't we begin by representing each natural number as an infinite bit string? So that 0 = 00000000000..., 9 = 1001000000..., 255 = 111111110000000...., and so on.  If we could, then the diagonal argument would imply that there is a natural number not in the natural numbers, which is a contradiction.
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?
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.
1890
From the :  [1,4,9].map(Math.sqrt)   will yield:  [1,2,3]   Why then does this:  ['1','2','3'].map(parseInt)   yield this:  [1, NaN, NaN]   I have tested in Firefox 3.0.1 and Chrome 0.3 and just as a disclaimer, I know this is not cross-browser functionality (no IE).  I found out that the following will accomplish the desired effect. However, it still doesn’t explain the errant behavior of parseInt.  ['1','2','3'].map(function(i){return +i;}) // returns [1,2,3]