How to make calculator round to nearest tenth

旧街凉风 提交于 2019-12-13 08:05:21

问题


I am building a calculator but when you start with decimals it won't round to the nearest tenth like I want it to. Anyone's help would be greatly appreciated. https://fuzzyandroidblog.wordpress.com/ I added it here wouldn't let me post for some reason thanks for help


回答1:


Use a NumberFormat with maximum fraction digits of 1 to format a floating point value to a string representation with at most one number after the decimal point.



来源:https://stackoverflow.com/questions/27422365/how-to-make-calculator-round-to-nearest-tenth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!