TutorialsCourses
Course Menu
Master React Native Animations

Modulo

Returns the non-negative modulo of the 2 values. Modulo is the remainder after division. The modulo JavaScript operator is the %. Modular arithmetic is commonly used in time calculations, but there are many other usages as well.

Here is a quick math demo of the % in action.

Essentially, you do the division of the 2 values. Take the result multiplied by the divisor (bottom number), then take the dividend (top number) and subtract out the resulting number. That values is the modulus.

16 % 6 = 4

//OR

16 \ 6 = 2
2 * 6 = 12
16 - 12 = 4
const dividend = new Animated.Value(16);
const divisor = new Animated.Value(6);

const modulo = Animated.modulo(dividend, divisor);

// value = 4;

Live Demo