Is scientific notation safe for integer constants in C?

前端 未结 6 732
心在旅途
心在旅途 2021-02-03 18:04

For a while, I\'ve been representing large powers of 10 in constants using scientific notation, just so I don\'t have to count the zeros. e.g.

#define DELAY_USE         


        
6条回答
  •  误落风尘
    2021-02-03 18:43

    It's really not safe because the compiler will consider it as a floating point number, so the precision is limited to 53 bits instead of 64 bits of integers (long int) for more you can read about the presentation of floating point numbrers

    http://en.wikipedia.org/wiki/Floating_point

提交回复
热议问题