On the image the highlighted 0.03 should be 0.04 but showing 0.03 and coin needed should be 10 but showing 9  My Code:   #include &lt;stdio.h&gt;  int main(){      double coins[6] = {0.01,0.05,0.10,0.25,1,2};     double ans[15];     double V = 5.64;     int j=0,i=5,Tcoin = 0;     while(V&gt;coins[0])     {         if(coins[i]&lt;=V)         {             j = V/coins[i];             //printf("%.2lf - %.2lf = %.2lf\n",V,j*coins[i],V-(j*coins[i]));//This is for testing purpose             V = V-(j*coins[i]);             Tcoin += j;         }         i--;     }     printf("Number of coin needed is: %d\n",Tcoin);      return 0; }
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
In ubuntu 11.04 there was a workaround using gconf-editor and setting key /apps/gnome_settings_daemon/plugins/xrandr/active to false.  However there is no such key in gconf-manager using ubuntu 11.10 (gnome 3). Exception thrown inside catch block - will it be caught again? This may seem like a programming 101 question and I had thought I knew the answer but now find myself needing to double check. In this piece of code below, will the exception thrown in the first catch block then be caught by the general Exception catch block below?  try {   // Do something } catch(IOException e) {   throw new ApplicationException("Problem connecting to server"); } catch(Exception e) {   // Will the ApplicationException be caught here? }   I always thought the answer would be no, but now I have some odd behaviour that could be caused by this. The answer is probably the same for most languages but I'm working in Java. So, the question pretty much says it all. I'm on Snow Leopard, and I do a lot of web development, particularly in Rails 3 which makes heavy use of the console.  I've seen some notable bloggers etc. mention Zsh as their preference over Bash, but I don't know what difference it would make.  Could anyone give me a good comparison of what difference there is and what might make one prefer one option or the other? Can bug reports and feature requests requiring SE Dev attention be reported on per-site metas, or do they need to all go here? "The product key entered does not match any of the Windows image" I have a HP with Windows 7 installed. I want to do a clean installation of Windows 8 from a bootable DVD.   I purchased my Windows 8 32-bit core from the Microsoft store and I received my product key. I then burned the .ISO file to a blank DVD using imgburn. When I restart and change my BIOS to boot from internal CD/DVD and then boot from my internal DVD, I start the installation process.  After I pass the screen where I select the language and location, and click Install it stays there for a minute and then it says:     The product key entered does not match any of the Windows image   I did my research and learned that I need to add a PID.txt file to my source file containing the Windows 8 .ISO but the thing is: I do not know how to add files to the .ISO. The guide I researched is for a bootable USB and I am using a DVD. Do you have to pass delete the same pointer that was returned by new, or can you pass it a pointer to one of the classes base types?  For example:  class Base { public:     virtual ~Base();     ... };  class IFoo { public:     virtual ~IFoo() {}     virtual void DoSomething() = 0; };  class Bar : public Base, public IFoo { public:     virtual ~Bar();     void DoSomething();     ... };  Bar * pBar = new Bar; IFoo * pFoo = pBar; delete pFoo;   Of course this is greatly simplified.  What I really want to do is create a container full of boost::shared_ptr and pass it to some code that will remove it from the container when it is finished. This code will know nothing of the implementation of Bar or Base, and will rely on the implied delete operator in the shared_ptr destructor to do the right thing.  Can this possibly work? My intuition says no, since the pointers will not have the same address.  On the other hand, a dynamic_cast&lt;Bar*> should work, so somewhere the compiler is storing enough information to figure it out.  Thanks for the help, everybody who answered and commented. I already knew the importance of virtual destructors, as shown in my example; after seeing the answer I gave it a little thought, and realized the whole reason for a virtual destructor is this exact scenario. Thus it had to work. I was thrown by the absence of a visible means of converting the pointer back to the original. A little more thinking led me to believe there was an invisible means, and I theorized that the destructor was returning the true pointer for delete to release. Investigating the compiled code from Microsoft VC++ confirmed my suspicion when I saw this line in ~Base:  mov eax, DWORD PTR _this$[ebp]   Tracing the assembler revealed that this was the pointer being passed to the delete function. Mystery solved.  I've fixed the example to add the virtual destructor to IFoo, it was a simple oversight. Thanks again to everyone who pointed it out. Significance of the second focus in elliptical orbits I'm new to latex, I'm thankful if someone can give me an example script to customize TOC that looks like  Chapter 1.XXXXXX                                                            (1-15)  1.1 Introduction 1.2 xxxxxxxx 1.3 xxxxxxxxxx 1.4 xxxxxxx ...............  Chapter 2.xxxxxxx  2.1 xxxxx ......                                                           (16-30)  because the (default) TOC appears to be very large for my book, since it arranges the section name row-by-row. How do I add CSS & JavaScript to ? I want to add the following code in my  section of the front page using a Drupal 8 sub theme of Bartik.   Can anybody help how to do it? What is the best way to do it in this new twig version of theme? Where is page.tpl?  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="stepcarousel.js"&gt;&lt;/script&gt; Expanding electromagnetic field Lagrangian in terms of gauge field How do you deserialize json properties that are reserved words in apex? Given the following HTML:   &lt;div id="container"&gt;   &lt;!-- Other elements here --&gt;   &lt;div id="copyright"&gt;     Copyright Foo web designs   &lt;/div&gt; &lt;/div&gt;    I would like #copyright to stick to the bottom of #container. Can I achieve this without using absolute positioning? Double dispatch in C#? What is the relationship between philosophy and science? While philosophy and science as held as separate disciplines (and often taught in completely different colleges within a university [i.e. College of Liberal Arts vs. College of Science]), it is patently clear that there is an immutable relationship between philosophy and science. Philosophy can often be seen as providing justification for particular scientific theories -- but why/how is this so?  In science:   A theory must have observable consequences that can be tested and be falsified.   Theories also must agree with previous theories in the domains where they had been successfully tested.   For example,  special relativity reduces to Newton mechanics in the domain of velocities much less than the speed of light.  In philosophy, while new theories must comply with existing theories, there is clearly much less testing/retesting.  So, how does philosophy fit into this framework while maintaining the rigor required for scientific inquiry?  Are there any examples of philosophical discussions that have significantly influenced or changed scientific theory? Disable the guest user completely in El Capitan without having to disable 'Find My Mac' I know it should be straight forward but unfortunately, it  isn't.  I did disable the guest user in the System Preferences by unchecking the checkbox for Allow guests to login in to this computer, but it still shows up on the login screen.  I have heard that disabling 'Find My Mac' would fix it for OS X Lion, but I want to keep it.  Is there a way to do this? This is a bit of a more unusual bug to report:    The screenshot above is unedited - the black box is rendered by the Stack Exchange application.  Phone:  running Android 4.0.4 (ICS) Pass shell variable as a /pattern/ to awk Having the following in one of my shell functions:  function _process () {   awk -v l="$line" '   BEGIN {p=0}   /'"$1"'/ {p=1}   END{ if(p) print l &gt;&gt; "outfile.txt" }   ' }   , so when called as _process $arg, $arg gets passed as $1, and used as a search pattern. It works this way, because shell expands $1 in place of awk pattern! Also l can be used inside awk program, being declared with -v l="$line". All fine.  Is it possible in same manner give pattern to search as a variable?  Following will not work,  awk -v l="$line" -v search="$pattern" '   BEGIN {p=0}   /search/ {p=1}   END{ if(p) print l &gt;&gt; "outfile.txt" }   '   ,as awk will not interpret /search/ as a variable, but instead literally. How can I move Steam games to another disk? How could it possible to factorise $x^8-1$ in product of irreducibles in the rings $(\mathbb{Z}/2\mathbb{Z})[x]$ and $(\mathbb{Z}/3\mathbb{Z})[x]$? How could it possible to factorize $x^8-1$ in product of irreducibles in the rings $(\mathbb{Z}/2\mathbb{Z})[x]$ and $(\mathbb{Z}/3\mathbb{Z})[x]$?  I'm having a hard time starting the problem. Could anyone help me at this point? Is it possible to shutdown remote Computers without inputing the password? I used the following bash to shutdown remote computers,but for each computer,I must input the password for it.Is it possible to input the password Automatically?   #!/bin/bash  ssh -t root@192.168.1.11 "sudo poweroff" ssh -t root@192.168.1.12 "sudo poweroff" ssh -t root@192.168.1.13 "sudo poweroff" ssh -t root@192.168.1.14 "sudo poweroff" ssh -t root@192.168.1.15 "sudo poweroff" ssh -t root@192.168.1.16 "sudo poweroff" ssh -t root@192.168.1.17 "sudo poweroff" ssh -t root@192.168.1.18 "sudo poweroff" ssh -t root@192.168.1.19 "sudo poweroff" ssh -t root@192.168.1.20 "sudo poweroff" ssh -t root@192.168.1.21 "sudo poweroff" ssh -t root@192.168.1.22 "sudo poweroff" ssh -t root@192.168.1.23 "sudo poweroff" ssh -t root@192.168.1.24 "sudo poweroff" ssh -t root@192.168.1.25 "sudo poweroff" ssh -t root@192.168.1.26 "sudo poweroff"