title: Check if a number is within 1/1000th of a half digit ( 0, 0.5, 1)
body: <p>So I'm studying for a programming midterm and one of the subjects is analyzing user inputted numbers.
  For example. User enters in X. Program tells if X is within 1/1000th of a half digit ( ...-1, -0.5, 0, 0.5, 1...) and gives you the number that it is closest to.
  I.E.
  input(1.50001) 1.50001 is close to 1.5
  is there a way to do this in a fashion simpler than I am trying to achieve below?</p>
  
  <pre><code>N = input("Enter a number: ")
  num = float(N)
  x = float(N) % 2
  print("remainder: ", x)
  if x &gt; 1:
      num = float(N) - x
      x = x - 1
  if x &gt; float(0.4) and x &lt; float(0.9):
      num = float(N) + x
      x = abs(x - 0.5)
  if x &lt; float(1/1000):
      print("Your number: ", x , " is a near half with ", num)
  </code></pre>
  
  <p>Sorry if this seems like a dumb question. I just can't seem to think of a good algorithm for something such as this.</p>