Float doesn't change when i add 0.1 to it

后端 未结 3 1098
感情败类
感情败类 2021-01-12 21:38

I am quite a newbie to c. So when i writing a small game demo, i face a really strange problem.

 void testC()
 {
     float a = 825300160;
     float b = a +         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-12 22:18

    There's not enough precision in the float type. If you really need to distinguish a 0.1 addition to a number as large as 825300160, use double.

提交回复
热议问题