My current method of rounding to x decimal places:  public static float roundInc(float value, float increment) {     float inc = 1f / increment;     return Math.round(value * inc) / inc; }   Which works fine for certain numbers, but seems to break, and I can't seem to figure this out.  I pass through the value 2.109375 Output of the function returns 2.11 Then I add that to 5.0 (is also a float, stored in a float array (float[])), and for some bizarre reason, adding the 2.11 + 5.0 returns 7.1099997...  Can someone explain this? Cause as far as I can see, after printing the two 2.11, and 5.0, showing those two exact values, then added together breaks everything...
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
Mac OS X Darwin: how to reset admin password? I have a live USB made with the standard Ubuntu disk image creator for 16.04 LTS. In the current state, I can boot to this disk, but it still requires the original USB to run properly at all times.  Attempting to pull the drive and use the system generates a large amount of I/O errors, further suggesting that the USB drive is actually needed for things not already loaded into RAM (For example, Firefox worked without the USB, but I used it once before already. apt, on the other hand, did not.)  Is there a way to copy the entire Ubuntu live disk to RAM, so I can remove the drive and free up a USB slot for other things? In which cases is a comma/period placed inside or outside of parentheses? Are there cases where a period is placed inside parentheses? In which cases the period (or a comma) should be placed inside the parentheses? I have a SRD-12VDC-SL-C relay with this configuration:  And I want to trigger it with PIR Motion Sensor Detector Module HC-SR501  The problem with direct connection to PIR is, when I connect PIR with 12v DC the Relay remains always ON, i.e. trigger from PIR does not switch it off. And when I connect it via 5V supply the Relay remains always OFF. The trigger output of PIR is 3.3V how can I rectify this problem? by adding some resistor/FETs, or something else. Edit: The voltage at Relay-In(Green) is 10.5V and the relay is OFF it need to go below 9V in order to switch the Relay ON. When I connect it to PIR trigger it goes down to 2.7V (Thus Switching ON the relay, below 9V). And when the PIR trigger of 3.3V comes it goes up to 7.2V but because it is still below 9V) Relay does not switch. Differentiation - simple case In the book calculus made easy, page 22 the case of the negative power for   $y=x^{-2}$    $$\begin{align}  y+dy &amp; =(x+dx)^{-2}\tag{1}\\ \\ &amp; = x^{-2}\left(1+\frac{dx}{x}\right)^{-2}\tag{2} \end{align}$$  How do they get from $(1)$ to $(2)$?  And why isn't the binomial function applied to the second line but applied on the third line (the line that comes after line $(2))$? Extracting phone number from string What time does sound good to you?     What time sounds good to you?    Is there a difference? Prove or disprove: If H is a normal subgroup of G such that H and G/H are abelian, then G is abelian. it seems like it... should be? In that I can't think of any counterexamples off the top of my head. I was looking up these  and saw the quaternion group, but the subgroups of the quaternion group aren't abelian... Select translation: where? Why do I need 50 reputation to comment? What can I do instead? Users with less than 50 reputation points cannot write comments on questions and answers that they don't own.  Why does this limit exist? But I want to contribute now. What should I do instead? But I can't write a good answer without more information! Shouldn't I be allowed to post comments if I have reputation on a different site? But I saw a new user posting a comment! How did they do it? Why do I need 50 reputation to comment on my own post?   See also:    in the Help Center I made a huge project, wanted to reduce file size from 1.3GB to below 1GB. Compressing did not help. I removed objects from scene. Also textures. I then realized, the file size even was the same when I delete ALL objects. Why?  Download of sample:   Before deleting all: 1.2GB, after: 1.1GB. How do I reinstall Unity? I tested out Unity 5, and of course, it broke things, so I tried downgrading by    sudo apt-get install ppa-purge sudo ppa-purge ppa:unity-team/staging   It removed Unity completely.    apt-get install unity   seemed to work, but the login screen now offers only Gnome.  How do I get back to Unity 4? Area of intersection between two circles Suppose you have 2 circles that intersect each other in such a way that each circle passes through the other's center. What is the area between the circle(or common area) i.e. area between the centres of the circles? Correct use of will & would? What would be the correct use of will &amp; would in these sentences?  1) What will happen if I say to my boss that I will not come tomorrow?  2) What will happen if I would say to my boss that I will not come tomorrow?  3) What will happen if I will say to my boss that I will not come tomorrow?  4) What would happen if I would say to my boss that I will not come tomorrow?  There are four sentences which one should I use and in which situation? Were there any improvements to the second Death Star (other than the change in exhaust port) that we know of? We know that the second Death Star was meant to have a different/non-existent exhaust port and when under construction it had a shield projected around it.  Other than these elements, one of which was planned to be totally temporary, do we know of any other improvements over its predecessor?  Did it have improved defences against one-man fighters? Did its laser charge more quickly? Did it have an upmarket cafeteria? This problem comes from another equation on another question (. I tried to split it in half but I found out that $$\sum_{k=0}^\infty \frac{k}{2^k}$$ can't be divided. Knowing that $$\sum_{k=0}^\infty x^k=\frac{1}{1-x}$$ I wrote that $$\sum_{k=0}^\infty \frac{k}{2^k}=\sum_{k=0}^\infty \left(\frac{\sqrt[k] k}{2}\right)^k=\frac{1}{1-\frac{\sqrt k}{2}}=\frac{2}{2-\sqrt[k] k}$$ But that's not what I wanted. Could anyone help me? I have come across these three definitions of the limit superior (or upper limit) and the limit inferior (or lower limit) of a sequence of real numbers and I wonder how to establish the equivalence of these.    Walter Rudin: PRINCIPLES OF MATHEMATICAL ANALYSIS, 3rd edition:  Definition 3.16: Given a sequence $\{s_n\}$ of real numbers, let $E$ be the set of numbers $x$ (in the extended real number system) such that $s_{n_k} \to x$ for some subsequence $\{s_{n_k}\}$. This set contains all subsequential limits ..., plus possibly the numbers $+\infty$, $-\infty$. We now ... put  $$s^{*} = \sup E,$$ $$s_{*} = \inf E.$$ The numbers $s^{*}$, $s_{*}$ are called the upper and lower limits of $\{s_n\}$; we use the notation  $$ \lim_{n \to \infty} \sup s_n = s^{*}, \, \, \, \lim_{n \to \infty} \inf s_n = s_{*}.$$ Tom M. Apostol: MATHEMATICAL ANALYSIS, 2nd edition:  Sec. 8.3: Definition 8.2: Let $\{a_n\}$ be a sequence of real numbers. Suppose there is a real number $U$ satisfying the following conditions:    i} For every $\epsilon &gt; 0$ there exists an integer $N$ such that $n &gt; N$ implies $$a_n &lt; U + \epsilon.$$ ii) Given $\epsilon &gt; 0$ and given $m &gt; 0$, there exists an integer $n&gt; m$ such that $$a_n &gt; U - \epsilon.$$ Then $U$ is called the limit superior (or upper limit) of $\{a_n\}$, and we write $$U = \lim_{n \to \infty} \sup a_n.$$ Statement (i) implies that the set $\{a_1, a_2, a_3, \ldots \}$ is bounded above. If this set is not bounded above, we define $$\lim_{n\to\infty}\sup a_n = +\infty.$$ If the set is bounded above but not bounded below and if $\{a_n\}$ has no finite limit superior, then we say $\lim \sup_{n\to\infty} a_n = -\infty$. The limit inferior (or lower limit) of $\{a_n\}$ is defined as follows: $$\lim_{n\to\infty}\inf a_n = -\lim_{n\to\infty}\sup b_n,$$ where $b_n = -a_n$ for $n= 1, 2, 3, \ldots$.    Robert G. Bartle and Donald R. Sherbert: INTRODUCTION TO REAL ANALYSIS, 3rd edition: Exercises for Section 3.3: Problem 10: Let $(x_n)$ be a bounded sequence of real numbers, and for each $n\in \mathbb{N}$ let $s_n \colon= \sup \{x_k \colon k \geq n\}$ and let $t_n \colon= \inf \{x_k \colon k \geq n\}$. Prove that $(s_n)$ and $(t_n)$ are monotone and convergent. Also prove that if $\lim (s_n) = \lim (t_n)$, then $(x_n)$ is convergent. [One calls $\lim (s_n)$ the limit superior of $(x_n)$ and $\lim (t_n)$ the limit inferior of $(x_n)$.]   Now how can one show that the above three definitions are equivalent (i.e. these three definitions are of the same pair of numbers)? So I'm working on this class that's supposed to request help documentation from a vendor through a web service. I try to name it DocumentRetriever, VendorDocRequester, DocGetter, but they just don't sound right. I ended up browsing through  for half an hour trying to come up with an adequate word.   Start programming with bad names is like having a very bad hair day in the morning, the rest of the day goes downhill from there. Feel me? I would like to associate the last installed version of my Mac OS X application with a certain type of file. A little experimentation shows that the info.plist file seems to be read and interpreted by the operating system when launching the application, not when dragging the application bundle to the disk.  does not say much on that topic.  Is there any way, using a simple .dmg image as installation medium, to make sure the system associates that particular file type with my newly installed app without having to launch it first?  I should clarify that I want this to be done automatically during the installation (I don't want my users to have to do it themselves). The company I work for has asked me to attend a training class on the other side of the country.  However my situation is my drivers license expired a few days ago. I do however have a separate printed email stating that the license has been renewed.  This drivers license is my only ID that shows both my name &amp; photo.  Is it possible to be able to board a flight with the expired drivers license and the printed email showing that it was renewed?