java - Show float number on a button -
i'm writing application android, , have difficulties writing float value on button text. tried this:
float percentage1 = (level1/16)*100; string s = float.tostring(percentage1); percent.settext(s+"%"); and this:
float percentage1 = (level1/16)*100f; percent.settext(float.tostring(percentage1)); it's show me 0.0% on button. if has on idea how that, please respond!
(level1/16) computed in integer arithmetic; i.e. remainder discarded.
to remedy, use (level1/16.0)*100;. using 16.0 causes expression evaluated in floating point.
Comments
Post a Comment