简体   繁体   English

如何将int数赋给小数点后的double

[英]How to assign int number to double after decimal

Assume we have int x = 4 and I want to assign x as a digit after the decimal in the following double number: 假设我们有int x = 4并且我想将x分配为以下双精度数中小数点后的数字:

double value = 2.x;

so the value should be 2.4 因此该value应为2.4

How can I do that in Java? 如何用Java做到这一点?

一个简单的方程式应该有所帮助

double value = 2 + x / 10.0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM