Help with trimming a Double value
I have a method which takes a double value, and then processes it to output various double values depending on the input. I then use another method to remove duplicates from the ArrayList because the first method often processes the same output twice or thrice. The process I use to remove duplicates usually works fine, but I was testing it with loads of random values as the input, and I noticed that in one case there were two values the same:
one was 7.30000000001
So the method that removes duplicates didnt remove one of them because of the minor difference. So now I want to know how I can round the double values to 2 decimal places, e.g 7.30 in this case, and then I can remove duplicates after rounding.
Thanks in advance
p.s. I know how to format strings e.g. %.2f but I want to actually edit the double value to process it, rather than altering only the output.