I'm writing a program that prints an array containing the sum of the values of two arrays passed as parameters. It all works fine with the exception of the last double value. I want the last value to print as 3.1. Instead it's printing the following:  [5.9, 11.7, 2.4, 3.0999999999999996]  Not sure how to format to print otherwise as I'm not allowed to use a String to solve it. I'm not having that problem with the other values. Here's my code and thanks for the help!      import java.util.*;  class Sum {     public static void main (String [] args)     {         double [] a1 = {4.5, 2.8, 3.4, 0.8};         double [] a2 = {1.4, 8.9, -1.0, 2.3};          arraySum (a1, a2);          System.out.println (Arrays.toString (arraySum (a1, a2)));        }      public static double [] arraySum (double [] x, double [] y)     {         int length = 0;         double [] sum = new double [x.length];         length = x.length;              for (int i = 0; i &lt;= length - 1; i++)             {                 sum[i] = x[i] + y[i];             }          return sum;      } }
In my program I have one array with 25 double values 0.04 When I try to sum these values in a loop I get following results:  0.0 + 0.04 = 0.04 0.04 + 0.04 = 0.08 0.08 + 0.04 = 0.12 0.12 + 0.04 = 0.16 0.16 + 0.04 = 0.2 0.2 + 0.04 = 0.24000000000000002 0.24000000000000002 + 0.04 = 0.28 0.28 + 0.04 = 0.32 0.32 + 0.04 = 0.36 0.36 + 0.04 = 0.39999999999999997 0.39999999999999997 + 0.04 = 0.43999999999999995 0.43999999999999995 + 0.04 = 0.4799999999999999 0.4799999999999999 + 0.04 = 0.5199999999999999 0.5199999999999999 + 0.04 = 0.5599999999999999 0.5599999999999999 + 0.04 = 0.6 0.6 + 0.04 = 0.64 0.64 + 0.04 = 0.68 0.68 + 0.04 = 0.7200000000000001 0.7200000000000001 + 0.04 = 0.7600000000000001 0.7600000000000001 + 0.04 = 0.8000000000000002 0.8000000000000002 + 0.04 = 0.8400000000000002 0.8400000000000002 + 0.04 = 0.8800000000000002 0.8800000000000002 + 0.04 = 0.9200000000000003 0.9200000000000003 + 0.04 = 0.9600000000000003   Why on earth could that happen?!
Are there other schools for witches and wizards in the rest of the world? In the books they only speak of 3 schools, but what about Asian or American people?  And even more, were they affected by the events happening in Europe? round in PHP shows scientific notation instead of full number I'm trying to do an echo of a variable containing 1400000.  so there is written: echo round(1400000); this gives 1,4E+6 instead of the full number. Anybody an idea on how to display it fully? How can I disable the volume warning if you raise the volume too much? I have a DEM layer from ASTER satellite and I want to get the slope information from it.  I use terrain analysis > slope, but the output is so wrong. Why is that?  Here is the DEM:     And here is the "Slope" that is totally wrong. It should stretch the values from 0 - 89.9097 but it does not. How would I prove there is no smallest positive rational number? what is the best method to prove this statement? In an exam paper, there was a picture of an air stewardess in the aeroplane serving passengers. One of my pupils wrote the following:      The air stewardess works on an aeroplane.    Shouldn't it be the air stewardess works in an aeroplane? Java - when to use 'this' keyword I don't understand an answer. Should I add a comment, or post a new question? I recently (today) asked a question that received what seems to be a clear, concise answer, but one that's beyond my ability to understand (I'm at the cut-and-paste stage with JavaScript, and the answer seems to assume more knowledge than I actually have).  Is it considered better to ask follow-up questions as comments to the answer given, or should I post "fresh" questions to Stack to help me understand the answer that's been given? How do I disable the drum beat sound on the login screen? I would have expected System ▸ Administration ▸ Login Screen ▸ Play login sound to control this, but unchecking it does not prevent the drum beat sound from playing. How to keep an SSD in shape on Yosemite? As of OS X 10.10, Apple uses kext signing. Ever since it has become  to manually activate TRIM for third-party SSDs on OS X. That means users with non-Apple SSDs will sooner or later see degrading write speeds.   So I am wondering what are my options to avoid this situation. Some approaches I could think of imply additional problems:   Are you aware of any alternative approach, that does not require disabling kext signing?  Are there tools or tricks to manually clean up a SSD (i.e. issue a TRIM command)? If I decided to temporarily use a tool like TRIM Enabler how long would it need to be activated, in order to clean the disk?   To summarize: No TRIM on Yosemite. What can I do? Find the infinite sum of the series $\sum_{n=1}^\infty \frac{1}{n^2 +1}$ This is a homework question whereby I am supposed to evaluate:  $$\sum_{n=1}^\infty \frac{1}{n^2 +1}$$  Wolfram Alpha outputs the answer as   $$\frac{1}{2}(\pi \coth(\pi) - 1)$$  But I have no idea how to get there. Tried partial fractions (by splitting into imaginary components), tried comparing with the Basel problem (turns out there's little similarities), nothing worked. Definite Integral $\int_{-\infty}^{\infty}\frac{x\sin x}{(x^2+a^2)(x^2+b^2)}\,\mathrm{d}x$ $$\int_{-\infty}^{\infty}\frac{x\sin x}{(x^2+a^2)(x^2+b^2)}\,\mathrm{d}x$$  This is easy to evaluate with complex analysis but is there an elementary way (substitution, partial fractions, integration by parts)? How can I disable Ctrl+Q for all applications (system wide)? A lot of applications like Firefox, Chrome etc, get closed when I accidentally press Ctrl+Q instead of Ctrl+W because of the proximity of the Q and W keys on the keyboard. Is there a way this shortcut can be removed or reset on a system wide basis? Print leading zeros with C++ output operator? Thought Experiment - Poking a stick across a Black Hole's Event Horizon A long time ago, I remember hiding some really personal files on my computer. Something that nobody could ever find, so I buried them down pretty darn good.  Now to my problem, I don't remember where.   Do anyone know a way to scan a drive and list all hidden folders and/or files?   I know how to view hidden files in Windows, but as far as I know, there is no way to search for them? I've been looking for a program, but I couldn't find one - and now I'm here, asking the experts. ;)  I'd really appreciate any tips. Django Template Variables and Javascript When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}.  Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to be able to lookup details using an AJAX lookup based on the values contained in the variables passed in. Calling a parent window function from an iframe I want to make some changes to Windows that require using the Group Policy Editor (gpedit.msc).  Unfortunately the Group Policy Editor is not included with the Starter Edition, Home and Home Premium editions of Windows.  How can I install it? Problems with pie charts There seems to be in increasing discussion about pie charts.   The main arguments against it seem to be:   Area is perceived with less power than length. Pie charts have very low data-point-to-pixel ratio   However, I think they can be somehow useful when portraying proportions. I agree to use a table in most cases but when you are writing a business report and you've just included hundreds of tables why not having a pie chart?  I'm curious about what the community thinks about this topic. Further references are welcome.  I include a couple of links:         In order to conclude this question I decided to build an example of pie-chart vs waffle-chart.