rand_range(float from, float to), does it include from and to?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jz2010927

var a = rand_range(1.5, 2.5)

Is there a chance a = 1.5 or a = 2.5?
so the question is range is [from, to], or (from, to)?

:bust_in_silhouette: Reply From: Zylann

It’s extremely unlikely to ever obtain a or b exactly…

Having a look here: https://github.com/godotengine/godot/blob/master/core/math/random_pcg.h#L98

According to the implementation, the function is based on a 0…1 function which has a case of returning 0, so I’d say a is included. But you have to be extremely lucky to ever get it in your lifetime.

Thank you so much

jz2010927 | 2019-09-18 22:37