I am trying to correctly convert (parse) a string to float in java, for the number 5755.1115, example:  float fl = new BigDecimal("5755.1115").floatValue(); float fl = (float)5755.1115d;   The issue is that it always prints 5755.1113. It seems it loses precision (I also tried using MathcContext(10) for example but didn't work)  But if I try this in javascript it seems it is working:  var fl = parseFloat('5755.1115'); var str = "" + fl.toPrecision(8); console.log("number: " + str);   It prints the number correctly even if I don't use toPrecision() function.  Can anyone explain how can I achieve this also in Java?  EDIT: My mistake, I forgot to specify that I do not want to use double because I need to keep the data transmission at minimum.
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
This is a 2015 IMO problem.  It seems difficult to solve.     Find all triples of positive integers $(a, b, c)$ such that each of the numbers $ab-c$, $bc-a$, and $ca-b$ is a power of $2$.   Four such triples are $(a,b,c)=(2,2,2),(2,3,2),(3,5,7),(2,6,11)$. Necessary condition for square integrable functions? I'm studying Quantum Mechanics and I came across this which I don't quite understand: For a vector space of functions $f(x)$ to be square integrable (i.e $\int{|f(x)|^2dx &lt; \infty)}$, the necessary condition is $\lim_{|x| \to \infty}f(x) \to 0$. Can someone help me understand why that must be the case? I sort of understand that it must not blow up at the infinities but can a (continuous or piece-wise continuous) function have a non-zero finite value at the infinities and still be square integrable? Flattening a shallow list in Python Origin/reason for the expression "on the bus" instead of "in the bus" This is sort of a follow up to my question .  I was told a while ago that the reason why we use "on the bus" instead of "in the bus" is because back in the day buses were open, that is, they didn't have a roof.   Is this story correct or is there another reason why the correct expression is "on the bus", in spite of the fact that when one gets on the bus, he is actually inside the bus? Visiting the US after overstaying as a minor 13 years ago? Does a car use friction to move? When a car's engine injects fuel into the cylinder chambers, the reaction creates a force that generates rotational momentum to the shaft and over the transmission, it translates that power to the wheels, right?  But, something's bothering me, how does the car actually move, is it dependent on the force of friction? Wheels have a contact with the road in one exact point and when the drive gets to rotate them, a force is exerted on the road in the direction of movement and there is friction that is counteracting it.  Is the key to get a car properly moving to have the drive force equal or less than the force of friction to keep that point locked to the ground and use the rolling of the wheel for translational displacement ie. moving forward? If it's bigger than the force of friction, that would cause the wheels to spin in place?  Am I completely off or am I getting something right? If there's a knowledgeable person on this topic, I'd greatly appreciate some insight, perhaps even a bigger response with some basic vehicle physics. Is there a way to connect my MacBook Pro to two external monitors (either VGA or HDMI; no Thunderbolt) in such a way that the Mac screen serves as a third monitor?  What hardware do I need? Reference undefined in \section with amsbook I have a section that is devoted to the proof of a theorem, and hence I used  \section{Proof of Theorem~\ref{thm}}   Of course, because of the headers that are capitalized, it asks for \ref{THM} when producing the header, and I get an obvious error. What is the proper way to handle such a case? Below is a MWE:  \documentclass{amsbook} \usepackage{lipsum} \newtheorem{thm}{Theorem} \begin{document} \chapter{First Chapter} \section{The Theorem} \begin{thm}[Lipsum Theorem] \label{thm} \lipsum[1] \end{thm} \section{Proof of Theorem~\ref{thm}} \lipsum[1-23] \end{document}   When compiling I get:  LaTeX Warning: Reference `THM' on page 3 undefined on input line 14.   (each time it produces a header), and the header shows     `2. PROOF OF THEOREM ??' Using strtok with a std::string I have a string that I would like to tokenize. But the C strtok() function requires my string to be a char*. How can I do this simply?  I tried:  token = strtok(str.c_str(), " ");    which fails because it turns it into a const char*, not a char* I have Ubuntu 13.1 installed with the default window manager and DE.   I am trying to enable single click so I can open files and folders with only one click. I tried googling and all results said to open files, then go to preferences from top bar but my top bar has no options.  picture of desktop: How to define a bijection between $(0,1)$ and $(0,1]$?   Or any other open and closed intervals?   If the intervals are both open like $(-1,2)\text{ and }(-5,4)$ I do a cheap trick (don't know if that's how you're supposed to do it): I make a function $f : (-1, 2)\rightarrow (-5, 4)$ of the form $f(x)=mx+b$ by \begin{align*} -5 = f(-1) &amp;= m(-1)+b \\ 4 = f(2) &amp;= m(2) + b \end{align*} Solving for $m$ and $b$ I find $m=3\text{ and }b=-2$ so then $f(x)=3x-2.$  Then I show that $f$ is a bijection by showing that it is injective and surjective. The binomial sum   $$s_n=\binom{n+1}{0}+\binom{n}{1}+\binom{n-1}{2}+\cdots$$   satisfies the Fibonacci relation.   I failed to prove that $\binom{n-k+1}{k}=\binom{n-k}{k}+\binom{n-k-1}{k}$... Any hints or suggestions? Prove $\phi^n = \phi F_n + \text{(another Fibonacci number)}$ using mathematical induction. Can I load a .NET assembly at runtime and instantiate a type knowing only the name? Is it possible to instantiate an object at runtime if I only have the DLL name and the class name, without adding a reference to the assembly in the project? The class implements a interface, so once I instantiate the class, I will then cast it to the interface.  Assembly name:     library.dll    Type name:      Company.Project.Classname     EDIT: I dont have the absolute path of the DLL, so Assembly.LoadFile won't work. The DLL might be in the application root, system32, or even loaded in the GAC. Careers should allow me to add external (authored but not owned) GitHub projects under "other" Best Pattern For Adding Commentary in align Environment? I've been using the align environment to line up equations in proofs/explanations/etc and I like to place parenthetical commentary for each step, similar to the code below:  \documentclass{article} \usepackage{amsmath} \begin{document}  \begin{align*}   f(ax + by) &amp; = f(ax) + f(by) &amp; (By Property 1) \\              &amp; = af(x) + bf(y) &amp; (By Property 2) \\ \end{align*}  \end{document}   The problem I have with this is that the commentary completely distorts the overall alignment of the equation area; far too much space is allocated to the column containing the commentary.  I would like, insofar as it is possible, for the equations themselves to be aligned in the center of the page and for the commentary to simply appear on the right without affecting the overall justification of the equations. What's the best way to achieve this? What is a mixin, and why are they useful? First, this question is motivated by the imprecise question: Is there a sensible notion of parity (evenness and oddness) for real numbers?   Here are some properties a notion of parity for $\mathbb{R}$ should have:    It should be an equivalence relation on $\mathbb{R}$ with exactly two equivalence classes.  Each equivalence class should be dense in $\mathbb{R}$. There should be some kind of symmetry between the two equivalence classes. (This is intentionally imprecise.)   If we divide $\mathbb{R}$ into rationals and irrationals, this lacks symmetry, since the rationals have measure zero and are countable, while the rationals have infinite measure and are uncountable.   So we could require that each equivalence class be uncountable and/or have positive (or infinite) measure. Then take one equivalence class to be the rationals, union with countably many fat cantor sets with positive measure, and the other class its complement. Then both classes are now dense, uncountable, and have infinite measure. But again, symmetry is lacking. One of these classes is "uncountable everywhere" and has "positive measure everywhere" while the other does not.   I propose some definitions: A subset $A \subset \mathbb{R}$ is uncountable everywhere if for any open interval $(a,b)$, the intersection $A \cap (a,b)$ is uncountable. A subset $A \subset \mathbb{R}$ has positive measure everywhere if for every open interval $(a,b)$, the intersection $A \cap (a,b)$ has positive measure. We can see immediately that having positive measure everywhere implies being uncountable everywhere, since a positive measure set must be uncountable.   Finally, my questions:    Is there a partition of $\mathbb{R}$ into two sets that are both uncountable everywhere?  Is there a partition of $\mathbb{R}$ into two sets that both have positive measure everywhere?  Is there a partition of $\mathbb{R}$ into two sets that split each interval $(a,b)$ into two parts of equal measure?   Potential generalizations for extra credit: What about partitions of $\mathbb{R}$ with $n$ equivalence classes, where $n \in \mathbb{N}$, or even with countably many, or even uncountably many equivalence classes?  Note: If you've seen these definitions of uncountable everywhere or positive measure everywhere somewhere under a different name, please let me know. I've never found anything where other people were thinking about these notions.  EDIT: By "measure," I mean Lebesgue outer measure, so we don't have to worry about anything being measurable. My daughter, 13, has said she wants to be a boy. A little background: we moved to a new state a year and a half ago. In her new school, she felt isolated among her peers until she met a girl in art, and became good friends. She joined the drama club, and made  friends with some 8th graders. They joined “the diversity club”. This club is a LGBT club. The kids put on a play they wrote and starred in, which had homosexual connotations. “Romeo and Juliet”, but script  rewritten to include  2 females as the couple, for instance.   My daughter got so wrapped up in it, that her life was as if she was copying the play. She’s no longer friends with the friend from art, but remains close with the 8th grade crowd. They all labeled themselves. One week, my daughter said she was gay, then, changed to bi, then onto pan. (I had to google that one). Now she is emphatic about being disgusted with her body and wants to be a boy. She wants to donate all the “girly” clothes she picked out last year, and tossed out all the makeup she bought a few months ago.   All her life, she was the classic girly girl. She had crushes on boys, and she and this boy were inseparable since first grade. She was sad when it came time to move away. When we settled here, she became sullen and angry, putting herself down. She now sees a therapist who she really likes. We’ve been working on her self esteem issues. She’s wanting us to call her “he” and by a male name. I can’t do that. She’s my daughter. She is female. Had we seen this coming, maybe I could come to accepting. But it happened out of the blue.  Sometimes the old her comes back-I got a makeup sample and she was interested in trying it, looked at me, then quickly put it down and said “ewww, makeup”—just a few months ago, she bought a bunch. She’s now wanting to wear boys clothes and talks of wearing a suit to her prom. She is very impressionable, and seems affected by viral YouTube videos about kids coming coming out to their mothers, and the mothers gleefully embrace with happy tears. She has told me when she’s 18, she’s having her breasts removed.    Nothing seems normal to me anymore-in terms of how she always was-this new situation just doesn’t fit.  My gut tells me this is a phase.  I’m hoping it’s a phase. But with all I’m seeing in the media about this, I’m not sure. I love her; this is too much for me to process. I’m a stay at home mom; we were inseparable. I knew her. Until now.:(  She cut off all her beautiful hair, and wears boys shorts, baggy tee shirts, and bought this awful men’s deodorant spray. Please help me sort this out. I’m at my wits end.  Do you think this is a phase? Is this common? Scala 2.10 + Json serialization and deserialization