Java Modulus Operator Not Working Correctly I am writing a small program to give me the max amount of each coin category (quarters, dimes, etc) when I enter an amount. The modulus operator is not returning a correct value. For example, when I enter the amount "1.64", it should return: Quarters: 6, Dimes: 1, Nickels: 0, Pennies: 4.  But my problem is at pennies. It keeps returning 3 pennies only. Any input would be appreciated!  import java.util.Scanner;  public class Main{     public static void main(String args[]) {         Scanner in = new Scanner(System.in);         System.out.println("Enter amount: ");         double amount = in.nextDouble();          int quarters = (int)(amount / 0.25);         System.out.println("Quarters: " + quarters);          amount = (amount % 0.25);          int dimes = (int)(amount / 0.1);         System.out.println("Dimes: " + dimes);          amount = (amount % 0.1);          int nickels = (int)(amount / 0.05);         System.out.println("Nickels: " + nickels);          amount = (amount % 0.05);          int pennies = (int)(amount / 0.01);         System.out.println("Pennies: " + pennies);     } }   Enter amount:  1.64 Quarters: 6 Dimes: 1 Nickels: 0 Pennies: 3
Is floating point math broken? Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
how to prove $G_1$ and $G_2$ aren't isomorphic? Where is the usage of Ubuntu cloud guest image on OpenStack documented? I am having an access problem to some files and directories that I have tracked down to the group assigned to access them.    When I manually change the name of the group in the properties/permissions menu for a directory from the default setting (MyGroup) to www-data used by my Drupal Website, the directory error messages I get are gone.    There are a large number of files and directories that require this change.  If believe using chmod will change the owner which is set correctly and being new to Ubuntu, I am reluctant to experiment without a better understanding of how owner and groups work in the permissions settings.   What command changes the Group setting for a directory? Opposite of Alternatives Why is $ 561 = 3*11*17 $ the smallest Carmichael number? I just noticed a weird thing in my reputation tab on StackOverflow.    That last question mentioned (but not linked, had to find it via search):   I must have amnesia as I have no memory of ever interacting with this post. I don't even know what xampp and pdftk are so I don't know why I would even be interested in such a question. 2 reputation points more or less is not a big deal, but the fact I got rep change from question I've never seen before is odd and I'm wondering what happened. Is time travel possible? Is it possible to go back in time? I read somewhere that according to relativity, it is possible - involving black holes and other stuff - to jump into the past. Is it possible for anything to go back in time either continuously or by jumping? Integral involving Cosine function What will be the formula for the following:  $$\int_0^\infty \cos(x)dx.$$ How to develop a SharePoint Designer Workflow Action for use in SharePoint (2013) online echo "#!" fails -- "event not found" Recently, the titles to some questions have been displaying as "undefined":    "undefined" is replaced with the question's true title upon refreshing the page. Is this a bug? What is the function of "do" in this sentence? Rarely, though, do countries introduce a single reform alone.   What function does do have in this sentence? CDN: How is it possible that my DNS delivers a different IP depending on the visitors location? I found  how a CDN works. But there is one thing I don't really understand. Let's assume I setup multiple DNS servers at my location and they use the nameserver domains dns1.example.com, dns2.example.com and dns3.example.com. This DNS servers are able to deliver a server IP depending on the visitors location (ping, geo database, browser language or whatever). Now I update this nameserver settings for my domain www.example.org at the registry.  Now, the very first request on www.example.org with an expired TTL tries to resolve the domain. It asks:   the local .hosts/DNS, if TTL expired: the internet providers DNS, if TTL expired: the root DNS, if TTL expired: my local dns1.example.com   But if I understand it correct, the new IP is then added to all these nameserver caches until the TTL expires again. So how is it possible to send other IPs to the visitor depending on his location?  In  theandym said the request is "forwarded", but I don't think this is how a CDN works, because "forwarding" means lengthen the transmission way resulting a longer loading time. Or does a CDN require zero TTL for the domain?  Update1 Through  I found  describing how they optimized CDN performance. It did not explain how the CDN works in general, but there were interesting explanations like the following:     Thereafter, whenever a client attempts to fetch content hosted on the   CDN, the client is redirected to the node determined to have the least   latency to its prefix. This redirection however is based on the prefix   corresponding to the IP address of the DNS nameserver that resolves   the URL of the content on the client’s behalf, which is typically   co-located with the client.   This means Google checks at first the latency of all IP prefixes and defines a DNS resolution table (?) for all available prefixes. And if a visitor has the IP 198.51.100.231 the Google server IP is used, that is set for the prefix 198.51.100.0. But again: How does Google's DNS know which IP the visitor is using? Most visitors resolve Google's domain through their internet provider and by that the resolving is done through those external DNS servers or not?  As an additional example: If I start a DNS resolution for the domain facebook.com with different online tools (hosted in different countries) it is resolved to different IPs with different domains like:   31.13.92.36 Reverse: edge-star-mini-shv-01-frt3.facebook.com 31.13.76.68 Reverse: edge-star-mini-shv-01-sea1.facebook.com 31.13.69.228 Reverse: edge-star-mini-shv-01-iad3.facebook.com 157.240.2.35 Reverse: edge-star-mini-shv-01-ort2.facebook.com   After that I thought it could depend on the DNS server location used by the visitor, but I tried my own (Deutsche Telekom, Germany), Google's (8.8.8.8) and a major one from France (Orange) and they all returned for facebook.com the IP 31.13.92.36. How to get git-completion.bash to work on Mac OS X? I have followed  to  add git-completion.bash to my /opt/local/etc/bash_completion.d/git-completion  and I put PS1='\h:\W$(__git_ps1 "(%s)") \u\$ ' in my .bashrc_profile  But now I am getting this -bash: __git_ps1: command not found everything I do a cd.  Can you please tell me what am I missing? Most statements regarding Riemann integrals (at least the ones that I have encountered) begin with the statement "for $f(x)$ bounded on $[a,b]$." I am wondering if Riemann integrability implies boundedness. I think that this has to be the case, but I am not sure. If Riemann integrability does imply boundedness, are improper integrals considered Riemann integrals? I would think that improper integrals wouldn't be Riemann integrals since improper integrals are allowed to be equal to $+\infty$ or $-\infty$. Or are improper integrals that are not equal to $\infty$ considered Riemann integrals?   I am confused. Try to do something vs. Try doing something Is there any differences between      Try to do   And     Try doing   Thank you in advence. Page number position Is there any way of doing something like,  &lt;script runat=server&gt;     Platform.Load("core","1");     //initialize DE     var _Sent = DataExtension.Init("_Sent");     //retrieve data     var _Sent_data = _Sent.Rows.Retrieve();     Write("Length: " + _Sent_data.length); //returns 0 &lt;/script&gt;   What would the external key for a system dataview be? How typeset a numeric table from a CSV file I have a CSV file (db.txt)like this:  30.0,   0.0,    0.0 60.0,   1.9098, 5.8779 90.0,   6.9098, 9.5106 120.0,  13.09,  9.5106 150.0,  18.09,  5.8779 180.0,  20.0,   0.0   I need to typeset it. My problem is related with the wrong alignment of decimal point and the number of decimals (must be a constant for each column):  \renewcommand*{\dtlrealalign}{r}  \DTLloaddb[     noheader,     keys={x,y,theta},     headers={         \shortstack{$\boldsymbol{\theta_{2,i}}$},         \shortstack{X},         \shortstack{Y}              }   ]{db}{db.txt} \begin{table}[t]   \caption{Database file}   \centering   \DTLdisplaydb{db} \end{table}     Any advice, please? On this site I see hundreds if not a thousand questions being asked about issues with a Wireless LAN adapter not being detected/recognized by Ubuntu. Some mainstream adapters appear to be utterly broken in Linux support, while others just require some simple steps to get it to work.  The options to get it to work appear to be infinitely huge and I have no clue where to get started!  What is considered 'best practice'? What order of things to try is most efficient in terms of time, effort and imposes minimal risk to my Ubuntu installation? Please help me save time and guide me what to do, step by step.