startlat = (double)((int)(SECornerLat * 100) / 100.0);//在33.

本文关键字:SECornerLat double int startlat | 更新日期: 2023-09-27 17:53:05

我想要一个小数点后只有两位数字的double

startlat = (double)((int)(SECornerLat * 100) / 100.0);

如果SECornerLat = 33.73,则startlat = 33.72。

我尝试了多个其他数字,它工作正常,但它返回错误的数字33.73。

same thing in Floor(33.73*100)/100.

startlat = (double)((int)(SECornerLat * 100) / 100.0);//在33.

这就是你想要的:

Double startlat = ((int) Math.Round((SECornerLat * 100), 0) / 100.0);

try this

startlat = (double)((33.73 * 100) / 100.0);