rounding my decimal float to nearest half or whole number?

前端 未结 1 1299
被撕碎了的回忆
被撕碎了的回忆 2021-01-14 00:41

Ok im having issues with my calculations in my app and im pretty sure that it is due to the decimals being to long. This is something that needs to be done anyway because it

1条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 01:15

    The easiest way is to take your final number, times 2 and round. Then divide by 2.

    (abHipAvg = (((ab1+ab2+ab3)/3)+((hip1+hip2+hip3)/3)));
    abHipAvg = roundf(abHipAvg * 2.0f) / 2.0f;
    

    and the same with neckAvg.

    0 讨论(0)
提交回复
热议问题