Modulo function
Copy link to clipboard
Copied
I have been using an Acrobat form.
The sum of a group of 16 form fields is totaled and divided by 16. Ex 101 / 16 = 6 remained 5. The integer (6) is multiplied by 3 = 18. The remainder is also multiplied by 3 =15. This (15/16) rounds up to 1 which is added to the previous value totaling 19. This final value is use to place the result in one of several groups. A if between 0 and 10, B if between 11 and 20, etc.
Is there a way to automate this operation? I tried to find if a Modulo function exists in Javascript without success.
101 / 16 = 6.3125.
Int 6.3125 = 6. 6 x 3 = 18
Modulo 6.3125 = .3125. .3125 x 3 = 0.9375 rounds up to 1
18 + 1 = 19
Thanks for any help.
Copy link to clipboard
Copied
It does. It's the % operator.
Run this code:
16 % 5
And it will return 1.
Copy link to clipboard
Copied
See this example, maybe you find something useful.
https://drive.google.com/uc?export=download&id=19NWjx84M0jnkPufMLdlobVMRM7yn2ksa

