How to get the 0 at the end of a double? This is what I have:  if (balance * 100 % 10 == 0) {     balance = balance + 0.00; } if (balance &gt; 0) {     return name + ", $" + balance; } else if (balance &lt; 0) {     return name + ", -$" + -balance; } else { // balance = 0     return name + ", $0.00"; }   I want to return "$4.80" but I keep getting "$4.8". How do I get the 0 at the end of the decimal?
How do I format a number in Java? How do I format a number in Java? What are the &quot;Best Practices&quot;? Will I need to round a number before I format it?  32.302342342342343 =&gt; 32.30 .7323 =&gt; 0.73  etc.
Alternative definitions of wifebeater I was a li'l nonplussed to find out that the word  can mean other things besides "a man who beats up his wife". Its definition reads:        One who (usually as a repeated practice) beats one’s wife, or a husband prone to violence   A kind of sleeveless shirt, often but not exclusively worn as an undershirt.   (uncountable, UK, slang) Stella Artois, a brand of lager beer.       reckons that sense 2 is American and originates "apparently from the association of such a garment with men who commit domestic violence". It does not register the UK slang. I'm guessing that Stellas also have an unfortunate association with domestic violence.  Are these alternative senses popular in their respective countries or are they perhaps nonce words that have lingered on? Any idea how these disparaging associations came about? I expect that the brewers of Stella Artois are none too happy about it. How do I install Komodo Edit? New to linux, help me install this program Komodo-Edit-7.1.0-10496-linux-x86_64  I'm running Ubuntu 12.04 64bit. How to find a Java Memory Leak How do you find a memory leak in Java (using, for example, JHat)? I have tried to load the heap dump up in JHat to take a basic look. However, I do not understand how I am supposed to be able to find the root reference () or whatever it is called. Basically, I can tell that there are several hundred megabytes of hash table entries ([java.util.HashMap$Entry or something like that), but maps are used all over the place... Is there some way to search for large maps, or perhaps find general roots of large object trees?  [Edit] Ok, I've read the answers so far but let's just say I am a cheap bastard (meaning I am more interested in learning how to use JHat than to pay for JProfiler). Also, JHat is always available since it is part of the JDK. Unless of course there is no way with JHat but brute force, but I can't believe that can be the case.  Also, I do not think I will be able to actually modify (adding logging of all map sizes) and run it for long enough for me to notice the leak. During my calculations I ended up with the following product: $$P=\prod_{n=1}^\infty e\left(\frac{n}{n+1}\right)^{n}\sqrt{\frac{n}{n+1}}$$ I tried to express it in terms of series by taking the logarithm  $$S=\ln P=\sum_{n=1}^\infty \ln\left(e\left(\frac{n}{n+1}\right)^{n}\sqrt{\frac{n}{n+1}}\right)$$ but I also got stuck. Numerical calculation suggests that it is equal to $$P\stackrel{?}=\frac{\sqrt{2\pi}}{e}$$ but I am not able to prove the conjecture. Any idea about how to evaluate the product? Any help would be appreciated. Thanks in advance. Choosing between meaningful and meaningless hostnames What element saved Iron Man from his blood poisoning? I just watched Iron Man 1&amp;2 the other day. I'm new to the entire story. In IM2 we learn that his blood is being poisoned and that he has tried every combination of every existing element as a cure - unsuccessfully. Then he deducts &quot;the key&quot; from the Expo park's plans which saves him. What is that key? What element had he not tried? I realize that the movie story has to be simplified, compared to the original story, so there are probably story elements that I have completely missed because they're only in the original works. We also saw that in LOTR. Is there only a single Skywalker family? Given the size of the Empire, it seems highly probable that names would be reused. Although I'm not aware of any in canon, there must be other Skywalkers in the galaxy, leading me to my question.  Are there other Skywalkers in the galaxy, and are they mentioned in canon? Does Luke have any third cousins twice removed (etc.)?  Bonus points if you can attest to force sensitivity among the surname. Can I be admitted to graduate school in a different field from my degree?  Specific cases include:   If I've taken plenty of advanced courses in field X in the process of completing a degree in another field, can I apply to graduate school in X? What if I haven't taken many courses in X, but I have acquired a good grasp of X through self-study or working in a related field? What if I've never studied X, but I have done very well in an unrelated field?  Could I be admitted to graduate school in X on the basis of general intellectual promise, and then make up the missing background after enrollment?   Note that this question is an attempt to provide a comprehensive answer, to avoid the need for a profusion of field-specific questions on this topic (see the associated ). Please feel free to edit the question or answer to improve them. How can I check if the editor that is currently being used is Gutenberg in a WordPress plugin?  I need this because Gutenberg lacks post_submitbox_misc_actions, so I need a fallback which will only be used if the current editor is Gutenberg. I want to try to convert a string to a Guid, but I don't want to rely on catching exceptions (   for performance reasons - exceptions are expensive for usability reasons - the debugger pops up  for design reasons - the expected is not exceptional   In other words the code:  public static Boolean TryStrToGuid(String s, out Guid value) {     try     {         value = new Guid(s);         return true;     }     catch (FormatException)     {         value = Guid.Empty;         return false;     } }   is not suitable.  I would try using RegEx, but since the guid can be parenthesis wrapped, brace wrapped, none wrapped, makes it hard.   Additionally, I thought certain Guid values are invalid(?)    Update 1   had a good idea to catch only FormatException, rather than all. Changed the question's code sample to include suggestion.    Update 2  Why worry about thrown exceptions? Am I really expecting invalid GUIDs all that often?   The answer is yes. That is why I am using TryStrToGuid - I am expecting bad data.  Example 1 . I might be parsing folder names, checking to see if the text after the final . is a GUID.  c:\Program Files c:\Program Files.old c:\Users c:\Users.old c:\UserManager.{CE7F5AA5-6832-43FE-BAE1-80D14CD8F666} c:\Windows c:\Windows.old   Example 2 I might be running a heavily used web-server wants to check the validity of some posted back data. I don't want invalid data tying up resources 2-3 orders of magnitude higher than it needs to be.  Example 3 I might be parsing a search expression entered by a user.     If they enter GUID's I want to process them specially (such as specifically searching for that object, or highlight and format that specific search term in the response text.)    Update 3 - Performance benchmarks  Test converting 10,000 good Guids, and 10,000 bad Guids.  Catch FormatException:    10,000 good:     63,668 ticks    10,000 bad:   6,435,609 ticks  Regex Pre-Screen with try-catch:    10,000 good:    637,633 ticks    10,000 bad:     717,894 ticks  COM Interop CLSIDFromString    10,000 good:    126,120 ticks    10,000 bad:      23,134 ticks   p.s. I shouldn't have to justify a question. Why does my Nikon D3100 give the error "Lens not attached" with a Vivitar 200 telephoto lens? I have a Nikon D3100 camera, and am trying to use an "Automatic Fixed Mount Vivitar 200mm lens" with it. When I attach the lens, I get the message "Lens not attached". and nothing works. HELP!  I can't easily take it to a camera shop, as I live in the Mojave Desert, about 200 miles away from any camera shop. This is a new lens, and a new camera. Heap versus Stack allocation implications (.NET) From an 1 about Heap and Stack, it raised me a question: Why it is important to know where the variables are allocated?  At  someone pointed that the stack is faster. Is this the only implication? Could someone give a code example where a simple allocation location change could solve a problem (eg. performance)?  Note that this question is .NET specific  1 the question is removed from SO. EntityFramework - contains query of composite key Which Windows 7 log file contains device connection/disconnection information? Windows 7 frequently plays the usb/new device connection/disconnection sound. It happens both when the computer is idle and under load. All usb device connections have been checked (though I can't rule out a bad cable yet). I thought a good way to track down the issue would be to wait for the sound and then check the log file for the latest connected/disconnected device. I just need to know which log file has this information.  Edit: I'm going to leave the answer accepted, however the issue persists. I get that sound seemingly randomly throughout the day. Anyone else have any ideas? Is there any uncountably infinite set that does not generate the reals? Does there exist an uncountably infinite set $X \subseteq \mathbb R$ such that $\mathbb R \neq \left&lt;X\right&gt;$? I can't think of any, but I'm also having trouble trying to prove that no such subset exists.  For example: $\mathbb R$ is uncountable and obviously $\mathbb R = \left&lt;\mathbb R\right&gt;$. The Cantor set $C$ is uncountable, and we know that $C - C = [0, 1]$, so then since $\mathbb R = \left&lt;[0, 1]\right&gt;$ we know that $C$ also generates $\mathbb R$. Also the set of irrationals $\mathbb R \setminus \mathbb Q$ is uncountable, but we can generate all the rational numbers by fixing one irrational number $\alpha$ and then saying the any rational number $x$ shall be $(\alpha + x) - \alpha$, since both $\alpha + x$ and $\alpha$ are irrational.  So the examples that quickly come to mind all generate the reals. Is there a simple counterexample? Why does changing a copy of an argument change the argument? Why are accepted answers not included in the tag badge calculation? For the 400 votes tag badge, does it take into consideration answers marked as the accepted answer?  The description indicates it does not.  I would think an accepted answer would be worth more, or at least the same amount, towards getting a tag badge than just a simple upvote?  Lots of users mark answers as accepted and do not bother giving an upvote since the 15 points is like and upvote and a tip.  So it's possible for a user to have 400 accepted answers with no upvotes and not get a badge where a user with 400 answers (which could be right or wrong) with a single upvote and no accepted answers ever would get the badge.  Just seems a little odd or does accounting for accepted answers make the badge calculation too complicated / slow?  Edit: Questions you ask and submit an answer to shouldn't be counted towards the total for accepted answers.  Edit: It just seems to me that the most important thing in the system is an accepted answer yet there are no badges for achieving more than one accepted answer.  If up votes were more important, and therefore far more worthy of a badge, then why do the top voted answers not appear above the accepted answer?  When it come to badges, accepted answers are second class citizens as compared to a possibly random upvote.   I have seen many upvotes on completely wrong answers but rarely do I see an accepted answer that was completely wrong. I am using BusyBox on a small embedded ARM system.  I'm trying to read the "top" output, in particular for the Python process listed.  How much real memory is this process using?  Also what does VSZ stand for?  The system only has 64MB of RAM.   Mem: 41444K used, 20572K free, 0K shrd, 0K buff, 18728K cached CPU:   3% usr   3% sys   0% nic  92% idle   0% io   0% irq   0% sirq Load average: 0.00 0.04 0.05 1/112 31667   PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND   777   775 python   S     146m 241%   3% /usr/bin/python -u -- dpdsrv.py A bounce-rate attack to manipulate SEO? This is a question to experienced people that might help us shed some light on the issue.   We noticed a very strange behavior on our site, in Google Analytics. Some dude from Finland, namely, from Kouvola city is hitting one of our pages - only one page on our site, 'bout a hundred times per day, all with an average bounce rate of 90%+...  This is causing our overall bounce rate to go up by 1 to 3% per day... which is very disturbing.. since we're trying to do our best in order to keep it as low as possible. And obviously having it jumped from ~24% to 27%, just because of that crazy dude is not making us happy at all... We tried implementing a geo-targeted script in order to catch this particular visitor and deliver him a juicy message, and it seemed like it helped in the beginning, it has stopped for a day or two, but now he's back...   The geo-targeted script was also logging all IP addresses for page requests originating from Finland in order to find out more details and (in order to block them on the server level, later).. but thing is, it was all mainly cable or DSL connections with various, but not constantly repeating IPs... we are all wondering what is he up to really ?   I think that this page should be kept updated with ideas on how to combat this and perhaps someone could also shed light on what it might be ? What is the reason for doing this "bounce-rate attack", as I call it?  There was a similar question asked on stackoverflow earlier, with no meaningful answer - here - I havent used my Ubuntu for quite a long time.  Today, when I booted Ubuntu (14.04 LTS), the software updater and Software &amp; Updates (from Settings) are not working.  The software updater's window will show up for around 1 sec, but it will close automatically. Software &amp; Updates is never shown, no matter how many times I click the icon. Note that neither of them show any error message.  Those 2 features were working perfectly the last time I used Ubuntu. I want to do some system upgrade and update.  For now, I use sudo apt-get update &amp;&amp; sudo apt-get upgrade. This command runs very fast, meaning (I think) my Ubuntu is not updated properly. The update from software updater always has a big size hence the download should be slower.  What should I do?   Can I just uninstall and reinstall both of them? If I can, how to do it?  Just to clarify, I don't want to upgrade my Ubuntu version (I want the LTS one), I just want to upgrade the software/packages I used.  Thanks for your time.