How to add modulo on calculator?

Hello mate,

Could you please take a look with my problem? I can’t find the function for modulo. I try use remainder of block but the result always showing NaN. Thank you in advance

I thought maybe the problem was that you were trying to get the remainder of a text string divided by a text string rather than numbers. But this test worked so that isn’t the problem:

You’re either dividing by zero or you’re getting extra characters in your variables.

What are you doing to verify that all of your variables have the values you expect them to have? I would recommend that when you display the variables in a label, you join a character before and after the value so that something like " 3" becomes • 3•, that way you can see the space in the result.

If that still doesn’t fix the problem, post a link to the project.

the way you are parsing is not correct. if you call it a modulo function, it usually takes the form of mod(11,7) but your parsing blocks seem to assume that operation is infix type - ie.
11 mod 7
if you expetc tthe statement this way, you may get the 1st variable correctly because it’s fond to he left of ‘mod’ but that parsing for the 2nd variableis not correct because you are start counting after the first letter of ‘mod’.
if you still prefer the function to be written in infix notation instead of as a procedure , you may want to use
% to avoid confusion . thus the above example would be
11 % 7
instead of
11 mod 7

iif you want ot be consistent and use the mod(11,7) notation - you have to set up a different method of parsing.- locate “mod”,find the parenthesis pair , split the text between using a comma.

Thank you for solution Mr.Tatiang, It’s work

1 Like

Thank you Mr. manyone

How did you fix the problem?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.