double and accuracy

后端 未结 3 1837
一生所求
一生所求 2021-01-17 03:23

Using long double I get 18/19 = 0.947368421052631578..., and 947368421052631578 is the repeating decimal. Using double I

3条回答
  •  无人及你
    2021-01-17 03:59

    A double typically provides 16(±1) decimal digits. Your example shows this:

         4   8  12  16
         v   v   v   v
    0.947368421052631578 long double
    0.947368421052631526 double
    

    The answers agree to 16 digits. This is what should be expected. Also note that there's no guarantee in the C Standard that a long double has more precision than a double.

提交回复
热议问题