SRL Archive - Help and Support

Mod


JPHamlett

2009-11-19 19:20:13

Can someone plz explain to me what mod does and the other things like div and that junk it would be a great help

TRiLeZ

2009-11-19 19:29:10

Mod is the remainder when dividing, div is to divide but only results an integer.

Example use of Mod:


Writeln(IntToStr(33 mod 8));

Bobarkinator

2009-11-19 19:45:13

Div will give you how many times a number can go fully into another number. Mod will give you the remainder of a Div function. But they don't have to be used in conjunction.

Nava2

2009-11-19 20:35:44

Div only returns integers, it truncates I believe as opposed to rounding.

Wanted

2009-11-19 21:11:04

Read above ^ it's good for finding patterns in code.

For example every 15 loads would be like if ((Loads mod 15) = 0) meaning if the Loads can divide by 15 and have a remainder of 0.

Floor66

2009-11-20 10:58:32

Mod (or modulus):

WriteLn(IntToStr(6 mod 4));

{ Would result in 2 (4 fits once inside 6, the remainder = 2) }

WriteLn(IntToStr(100 mod 30));

{ Would result in 10 (30 fits three times inside 100, the remainder = 10 }

Scaper

2009-11-20 17:57:29

open up scar and press F1

i found really helps :)