Page 1 of 1

Mod Question

Posted: Wed Apr 11, 2018 7:07 am
by RossG
Is there a function to give the whole
part of the number?

I've done it with a bit of code but just
feel that it's in.

Re: Mod Question

Posted: Wed Apr 11, 2018 8:57 am
by Klaus
Take the first word of your thread title and look that up in the dictionary!
Amazing, isn't it? 8)

Re: Mod Question

Posted: Wed Apr 11, 2018 1:07 pm
by RossG
Well, if I put 22 mod 5 the answer is 2 - the remainder.
whereas 22/5 is 4.4. The answer I want is 4 not 2.
Just coded it to delete char "." and following numbers.

While on the subject I wonder has anyone found a use
for "mod" and if so what was it.

Re: Mod Question

Posted: Wed Apr 11, 2018 1:13 pm
by FourthWorld
See trunc in the Dictionary.

Re: Mod Question

Posted: Wed Apr 11, 2018 1:15 pm
by Klaus
Oh, sorry, I was always weak in math! :D

You are looking for DIV:

Code: Select all

...
put 22 DIV 5
...

Re: Mod Question

Posted: Wed Apr 11, 2018 4:17 pm
by bogs
Klaus wrote:
Wed Apr 11, 2018 8:57 am
Take the first word of your thread title and look that up in the dictionary!
When I saw this last night, I had assumed he had looked up 'mod' in the dictionary, and it hadn't answered his question. So I went and looked it up, and it doesn't answer his question.
FourthWorld wrote:
Wed Apr 11, 2018 1:13 pm
See trunc in the Dictionary.
Klaus wrote:
Wed Apr 11, 2018 1:15 pm
Oh, sorry, I was always weak in math! :D
You are looking for DIV:
I also did not know, but apparently there are more than one way to get to where Ross wanted to go. Of course, you would have to kind of know exactly what your looking for in this case to figure out what to look for in the dictionary.

I wonder now if you did not know, how would you find out heh.
RossG wrote:
Wed Apr 11, 2018 1:07 pm
While on the subject I wonder has anyone found a use
for "mod" and if so what was it.
Well, that one I can link to. Basically, mod does a lot of things, but what I used it for most was dividing things into equal pieces, like scaling a picture, centering a window, etc.

Re: Mod Question

Posted: Thu Apr 12, 2018 3:23 am
by RossG
Thanks guys for your help.

I ended up with what I think is a nifty bit of code...

Code: Select all

 repeat with x = 8 to min(36,(field SCount div 4 * 4)) step 4
This was to avoid a "divide by zero" error.