float转int 四舍五入问题

xiaoxiao2021-02-28  150

[cpp]  view plain  copy  print ? int floatToInt(float f){       int i = 0;       if(f>0) //正数         i = (f*10 + 5)/10;       else if(f<0) //负数         i = (f*10 - 5)/10;       else i = 0;          return i;      }  
转载请注明原文地址: https://www.6miu.com/read-41411.html

最新回复(0)