I tried Math.round and String.format function to round float/double values.   1) Using Math.round function  Math.round(floatValue* 10.0) / 10.0;   For floatValue 40.55, result is 40.6 //Correct &amp; Expected result.  For floatValue 30.05, result is 30.0 //Incorrect result. Expected result: 30.1  2) Using String.format function  String.format("%.1f", floatValue);   For floatValue 40.55 result is 40.6    //Correct &amp; Expected result.  For floatValue 59.65 result is 59.6 //Incorrect result. Expected result: 59.7  Why same function is behaving differently for different float values.
What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations.  I also would like only significant digits to be displayed - i.e. there should not be any trailing zeroes.  I know one method of doing this is to use the String.format method:  String.format("%.5g%n", 0.912385);   returns:  0.91239   which is great, however it always displays numbers with 5 decimal places even if they are not significant:   String.format("%.5g%n", 0.912300);   returns:  0.91230   Another method is to use the DecimalFormatter:  DecimalFormat df = new DecimalFormat("#.#####"); df.format(0.912385);   returns:  0.91238   However as you can see this uses half-even rounding. That is it will round down if the previous digit is even. What I'd like is this:  0.912385 -&gt; 0.91239 0.912300 -&gt; 0.9123   What is the best way to achieve this in Java?
Is it common to use "where" after "a time" as a relative? I heard the following comment of Mr. Marco Rubio about Mr. Donald Trump on CBS’s “Face the Nation” in a clip in February 29th AP Radio News:  “There is never gonna be a time where the Republican Party rallies around and says you have to get out or anyone has to get out for purposes of rallying around Donald Trump. Donald Trump is not Republican Conservative. Donald Trump is trying to pull off the biggest scam in American political history.”  I thought I misheard “There is never gonna be a time where –“ for “There is never gonna be a time when –“ at first, because I was in understanding that time should be trailed by “when” as a relative noun or adverb. An English Japanese dictionary at hand (Readers English Japanese Dictionary published by Kenkyusha) provides “where” singly as a relative to refer the ‘place.’ However, my lookup of the following two sources endorsed that I heard it right:  Here is what is never going to happen in this race. There's never going to be a time where the Republican Party rallies around and says you have to get out or anyone has to get out for purposes of rallying around Donald..  “Here is what is never going to happen,” Rubio continued. “There's never going to be a time where the Republican Party rallies around and says you have to get out or anyone has to ...   Is it common, at least not uncommon to use “where” after “time” as a relative? How can I run Windows applications on a MacBook Pro? I have a friend that wants to buy a Mac Book Pro and he has some windows applications that he needs to run. He doesn't want to buy the applications again.  Can he run the Windows applications on his MacBook Pro? What ways to accomplish this are available? Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin An operator on the other side of the Schrödinger equation A form of the  is  $$     \left[-\frac{\hbar^2}{2m} \nabla^2 + V(\vec{r}, t)\right]\Psi = i\hbar \frac{\partial}{\partial t} \Psi $$  The bracketed term is of course the Hamiltonian, and the whole equation can hence be written as  $$     \hat{H}\Psi = i\hbar \frac{\partial}{\partial t} \Psi $$  My question is, is there a existing/named operator represented by $i\hbar \frac{\partial}{\partial t}$? That is, can we further rewrite the equation as  $$     \hat{H}\Psi = \hat{\Theta}\Psi $$  For some predefined operator $\hat{\Theta} = i\hbar \frac{\partial}{\partial t}$? Why can't the indefinite integral $\int\frac{\sin(x)}{x}\mathrm dx$ be found? I came across a list of functions in my calculus textbook whose indefinite integral cannot be found. It was written that the integral $$\int \frac{\sin(x)}{x} dx$$ cannot be evaluated without any explanation as to why.  I did some research over the internet and found out that the definite integral $$\int_{0}^{\infty} \frac{\sin(x)}{x} dx$$ can be evaluated using Laplace transformation and is equal to $\pi /2$. But I still couldn't find answer to my original question. I read somewhere that the integral cannot be expressed using 'elementary functions'. A little help is appreciated, I'm in Calc 1 going advanced than my course but I am sorry if my post shows lack of research. Thank you! I'm kind of stuck in Terraria. I have full silver armor and 12 hearts (gold/silver gear).  I have just killed the Eye of Cthulhu.  I was thinking about gathering gold armor, but gold is damn scarce. I have tried searching for floating islands (at 406 altitude) but if I go to far I get attacked by Harpies, and I can't build a sky bridge and fight them at the same time.  My meteorite landed in corruption and it's impossible to collect it (I get swarmed by meteor heads with no way to run).  So what is the most natural progression? Should I try and find gold (where?), try to kill the Eater of Worlds, try to mine meteorite or try to fight off imps and collect some hellstone? Can you nest html forms? Is it possible to nest html forms like this  &lt;form name="mainForm"&gt;   &lt;form name="subForm"&gt;   &lt;/form&gt; &lt;/form&gt;   so that both forms work? My friend is having problems with this, a part of the subForm works, while another part of it does not. R: Trouble using SMOTE package "invalid 'labels'" Using SMOTE package from DMwR library. After loading the data frame, I try to perform sampling as follows :   crime_bal$target &lt;- as.factor(crime_bal$target) crime_bal &lt;- SMOTE(target ~ .,crime_bal,perc.under = 200, perc.over = 100)   But it always ends up to this error :   Error in factor(newCases[, a], levels = 1:nlevels(data[, a]), labels = levels(data[,  :    invalid 'labels'; length 0 should be 1 or 2 In addition: Warning messages: 1: NAs introduced by coercion  2: NAs introduced by coercion    Details of my dataset :   &gt; summary(crime_bal)      text               url            target    Length:6326        Length:6326        0:5994    Class :character   Class :character   1: 332    Mode  :character   Mode  :character   Why do I always end up with the error? Shapes of planets? Getting always extra button on display .. 1 button dont have any ID I am having problem while looping.  I am always getting an extra button. Please help.   {this.state.items.map(myitems1 =&gt; {     return (        &lt;div key={myitems1.Id}&gt;            &lt;span&gt;{myitems1.Item_x0020_Name}&lt;/span&gt;            &lt;button onClick={e =&gt; this.dosometing(myitems1.Id)}&gt;Offline&lt;/button&gt;        &lt;/div&gt;     ); })}   I can see the collection has only three (3) values, But I am getting 4 buttons on screen.   Getting always extra How can I remove Ubuntu from my system and install the Windows bootloader? Let $b_n$ decrease monotonically to zero, prove $\sum b_nz^n$ converges for $|z|\leq 1$ and $z\neq 1$ How do you explain the value of native files to an uneducated client? If you design a piece for print. It gets reproduced several times over the course of a few years. Then the client doesn't return for any work for a few more years. And suddenly you are contacted asking for native files (Indesign, Illustrator, Photoshop). As the client puts it, "We just want to be able to make minor changes, we aren't designers."  Now, there is absolutely value in the native files. They are my "secret recipe" as a designer and anyone asking for that recipe should provide compensation for the ease of reusing, repurposing, and altering the recipe.  How do you explain to this client that there is value in the native files?  How do you counter the "But we already paid for the design." argument?  Note: I know I own the files. I know my contract states I own the files. Heck even without a contract, US Copyright law states I own the files.  What I'm seeking is an elegant, less argumentative, method of explaining the file ownership to the uneducated client. Reciting legal statutes and contract clauses doesn't often make for friendly client relations. My goal is to find a method of explaining so it is fully understood by the client without the appearance of a contract clause which forces them to do something against their will. I want the client to respect and not resent these types of contract clauses. In comics does Batman have a rule against killing? Inspired by  question, I have to admit I don't know a lot about the Comic Book Batman, but I know a fair amount about his other incarnations.   I know for example, that the 1989 movie had him kill the Joker. He vehemently wanted the Joker dead and had no compunctions about taking a life. I also know that he had a rule against killing in The Animated Series that he never broke, and that he very nearly broke it in Batman Beyond.  But as far as the comic books go, when did Batman develop a rule against killing his foes? Does he ever kill them rather than deliver them to the proper authorities? Why is Severus Snape's Patronus the same as Lily Potter's? Are Snape and Lily related somehow? Are Snape and Harry related? Why do the $n \times n$ non-singular matrices form an "open" set? Why is the set of $n\times n$ real, non-singular matrices an  open subset of the set of all $n\times n$ real matrices? I don't quite understand what "open" means in this context.  Thank you. Front suspension or full suspension mountain bike Please revoke badges gained by abusive voting In  (not feature request), :  ... if we find that people are abusing the system their accounts may get suspended. I would consider that kind of behavior abuse.  Well  sure qualifies. He has 11 Stack Exchange accounts and has in the last day spammed at least 8 of them to gain the Suffrage and sometimes Vox Populi badges. That's over 250 votes† in just a few hours! (And  -- while voting on other user's posts too.) I guarantee that he's not voting on those posts for/by their merits. Here's when he scammed the Suffrage badge per site (while also gaming the Vox Populi on some sites):                      - 2017-03-11 16:23:15Z                     - 2017-03-11 17:41:41Z                     - 2017-03-11 18:08:13Z                           - 2017-03-11 19:25:10Z                  - 2017-03-11 19:55:16Z                               - 2017-03-11 20:00:49Z               - 2017-03-11 20:03:13Z  - 2017-03-11 21:11:40Z  Note that he got the badge on three sites within an 8 minute span (but that might just be job run times). Please revoke badges gained through improper voting. And, maybe also warn/suspend such abusive voters.   † His account vote totals don't show all votes as some serial voting was reversed -- but none of the ill-gotten badges were. Is it possible to follow a user automatically? I've been looking around and I can't seem to find an automatic (i.e. buzz- or Twitter-like) way to follow users inside Stack Exchange. Why haven't the developers added such a feature? It could help beginner users follow other beginners with the same interests. We would be able to learn from each others' questions and pitfalls. Also, it would reduce double posting. Is it possible to kill people indirectly with the Death Note? in the Death Note states:        Whether the cause of the individual's death is either a suicide or accident, if the death leads to the death of more than the intended, the person will simply die of a heart attack. This is to ensure that other lives are not influenced.      However,  states:        Even though only one name is written in the Death Note, if it influences and causes other humans that are not written in it to die, the victim’s cause of death will be a heart attack      Besides the fact that I find these 2 rules to be contradicting (correct me if I'm wrong), it still made me curious: Is it possible to kill people indirectly with the Death Note?  For example, writing a heart surgeon's name during a operation, or a pilot's name while mid-flight.