is it possible to find random floats in range [a,b] in python?

后端 未结 5 2092
旧巷少年郎
旧巷少年郎 2021-01-06 17:07

I\'m trying to generate in python random floats in the range of [0.8,0.9] , but unfortanetly all the tools i found could only generate randoms in the range of [a,b) for floa

5条回答
  •  时光说笑
    2021-01-06 17:25

    The difference between [0.8, 0.9] and [0.8,0.9) is vanishingly small. Given the limitations of binary floating-point, I don't think there even is a difference, since 0.9 can't be precisely represented anyway. Use [0.8,0.9).

提交回复
热议问题