2

I am learning Java by debugging programs from various tutorials. At a moment I am fixing this calculator: http://www.dreamincode.net/forums/topic/321933-creating-a-calculator-using-jframe/
If you press "1/1" it displays "1.0" instead of "1". I am leaning towards

if (abs(result-round(result)) < 0.000000001){(int)(result)}

What would be an appropriate way to fix this glitch? Thank you in advance,

Stepan
  • 1,391
  • 18
  • 40

1 Answers1

1

I think you are close to what you want, but this code is probably the more correct way to do it:

if (abs(result-round(result)) < 0.000000001){(int)Math.round(result);}
Trey50Daniel
  • 179
  • 3
  • 14