convert double into int

2019-02-26 07:47发布

问题:

I have following double value: 8.943 need to convert(cast) into int e.g: 8.943*1000000 = 8943000 required value --> 8943000

please help!

thanks.

回答1:

double myDouble = 8.943
int myInt = (int) (myDouble * 1000000)

Using (int) casts the double into an int