Is scientific notation safe for integer constants in C?

前端 未结 6 729
心在旅途
心在旅途 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:38

    You'll never get rounding errors on something less than INT_MAX, since the specification for double sets aside 52 bits for you to use. Your "fractional component" is just your integer, and your "exponent" will be 1, and floating point doesn't struggle with that.

提交回复
热议问题