Home > Community Toolbox Reference > Math utilities > Euclidean division
Calculates a remainder from the Euclidian division (the remainder will always be non-negative).
Argument | Type | Usage | Description |
---|---|---|---|
dividend | Real |
Required | The dividend (i.e. the value to get the remainder of). |
divisor | Real |
Required | The divisor (i.e. the value to divide by). |
Real
The following code shows using Euclidean division remainder to cycle through menu options. It properly handles negative selected index that occurs when the player pressed up arrow key starting from selected index of 0.
if (keyboard_check_pressed(vk_up))
selected_index -= 1;
if (keyboard_check_pressed(vk_down))
selected_index += 1;
selected_index = eucmod(selected_index, options_count);
- 23.4.0 - Created a function to calculate the remainder of an Euclidean division.