本文介绍了将小数英尺转换为英尺和英寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将测量值从12.5英尺转换为12英尺6英寸?我将如何创建第二个数字,该数字在乘以12时仅读取小数位?
How would I go about converting a measurement from, for example, 12.5 feet to 12ft 6in? How would I created that second number which reads only the decimal place when multiplying by 12?
现在我可以使用其他变量和一些数学运算来获得Double Measurement01的双脚以十进制表示。我使用farf.setText(Measurement01 + + ft)将其发送到textview;
right now I have double Measurement01 using other variables and some math to get me the feet in decimals. I send that to a textview with farf.setText(Measurement01 + " " + "ft");
任何帮助将不胜感激!
推荐答案
减去整数部分:
float measurement = 12.5;
int feet = (int)measurement;
float fraction = measurement - feet;
int inches = (int)(12.0 * fraction);
这篇关于将小数英尺转换为英尺和英寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!