What's the first double that deviates from its corresponding long by delta?

前端 未结 4 1456
遥遥无期
遥遥无期 2021-01-18 18:14

I want to know the first double from 0d upwards that deviates by the long of the \"same value\" by some delta, say 1e-8. I\'m failing here though. I\'m trying to do this i

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 18:35

    Off hand, I thought that doubles could represent all integers (within their bounds) exactly.

    If that is not the case, then you're going to want to cast both i and d to something with MORE precision than either of them. Perhaps a long double will work.

提交回复
热议问题