title: How can I remove last digit off a decimal number in Java?
body: <p>For example, when I have 3.333 and when that code is executed, I need the number to be 3.33.</p>
  
  <p>This is the code I have which should be doing that, but doesn't:</p>
  
  <pre><code>String number = Double.toString(first);
  number = number.substring(0, string.length() - 1);
  first = Double.parseDouble(number);
  </code></pre>
  
  <p>I tried doing it by converting the number to a string, cutting off last character and saving it into a double again. But it doesn't work. Instead of cutting off 1 digit, it cuts off 2, for example above it would return 3.3.</p>
  
  <p>Is this method reliable and if yes, what can I do to fix it?</p>
  
  <p>Also, is there a chance for this method to crash the program (only decimal numbers go through that code) and would there be a loss in precision?</p>