title: Mirroring a number in Java, between a specified domain
body: <p>I need to make a mirroring of a a known domain (bounds are algebraic numbers) in Java language.</p>
  
  <p>The domain is between these two numbers, where the 50 is the mirror (50 must be excluded, 50 = 50)! The mirroring need to be in both directions (see examples).</p>
  
  <pre><code>0 ________ 50 ________ 100
  </code></pre>
  
  <p>What I want to achieve is this</p>
  
  <p>For example:</p>
  
  <pre><code>double x = 20; //x is my input number
  double mirrorX = newnumber_mirrored; //mirrorX is the number mirrored in the specified domain, so if the x is 20, the output must be 80.
  
  //other examples:
  //input x = 45, output = 55
  //input x = 48, output = 52
  //input x = 50, output = 50
  //input x = 50.1, output = 49.9
  //input x = 67.4, output 32.6
  </code></pre>
  
  <p>How can I achieve this in Java? Can be a precision of 1 or maybe 2 decimals, or maybe a fully precision.</p>