Mod Question

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Mod Question

Post by RossG » Wed Apr 11, 2018 7:07 am

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.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mod Question

Post by Klaus » Wed Apr 11, 2018 8:57 am

Take the first word of your thread title and look that up in the dictionary!
Amazing, isn't it? 8)

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Mod Question

Post by RossG » Wed Apr 11, 2018 1:07 pm

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.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Mod Question

Post by FourthWorld » Wed Apr 11, 2018 1:13 pm

See trunc in the Dictionary.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mod Question

Post by Klaus » Wed Apr 11, 2018 1:15 pm

Oh, sorry, I was always weak in math! :D

You are looking for DIV:

Code: Select all

...
put 22 DIV 5
...

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Mod Question

Post by bogs » Wed Apr 11, 2018 4:17 pm

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.
Image

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Mod Question

Post by RossG » Thu Apr 12, 2018 3:23 am

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.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”