如何使计算器轮最近的十分之一 [英] How to make calculator round to nearest tenth

查看:229
本文介绍了如何使计算器轮最近的十分之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个计算器,但是当你开始小数也不会轮最近的十分之一像我想它。任何人的帮助将大大AP preciated。 的https://fuzzyandroidblog.word$p$pss.com/ 我在这里补充它止跌让我看后由于某种原因,感谢您的帮助。

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

推荐答案

使用一个 的NumberFormat 以1最大比例数字格式化浮点值的字符串重新小数点后至多有一个数presentation。

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.

这篇关于如何使计算器轮最近的十分之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆