Random floating point double in Inclusive Range

后端 未结 13 680
感动是毒
感动是毒 2020-12-01 18:14

We can easily get random floating point numbers within a desired range [X,Y) (note that X is inclusive and Y is exclusive) with the function listed below since

相关标签:
13条回答
  • 2020-12-01 18:42

    The question is akin to asking, what is the floating point number right before 1.0? There is such a floating point number, but it is one in 2^24 (for an IEEE float) or one in 2^53 (for a double).

    The difference is negligible in practice.

    0 讨论(0)
提交回复
热议问题