Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
The function Math.random() generates a value between 0 and (very, very close to) 1. The value you get from this will be a decimal so Math.floor() is used to round down. The +1 is added as the random value will never be exactly 1. And when you multiple just your max value by 0.9999... and round down it will always end up 1 below that value. The minimum value is subtracted from the multiplication as it will later be added back to the final value.
For our example:
(0.9999 * 46) + 5
45.9954 + 5
50.9954 which is then rounded down to 50.
(0 * 46) + 5
0 + 5