{"name":"mod","title":"mod","type":"command","url":"https://community.bistudio.com/wiki/mod","revid":339102,"updated":"2023-04-26T10:54:26Z","groups":["Math"],"status":"ok","games":{"ofp":"1.00","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.00","arma3_since":"0.50","description":"Remainder of a divided by b.","syntaxes":[{"syntax":"a mod b","params":[{"name":"a","type":"Number","type_expr":"Number"},{"name":"b","type":"Number","type_expr":"Number"}],"returns":{"type":"Number","type_expr":"Number"},"form":"binary","left":{"text":"a"},"right":{"text":"b"}}],"examples":[{"code":["_remaining = 5 mod 2; // returns 1, as 5 divided by 2 is 2 × 2 + 1"]}],"aliases":["a % b"],"see_also":["Math Commands","Operators","a % b"],"notes":[{"user":"Hoz","date":"2006-04-16T01:34:00Z","text":"- Remainder is calculated in real domain.\n- mod is identical to a % b\n\nYou can use mod to round a decimal number down to the nearest whole number. For example: If you wanted to use the command random to generate a whole number between 0 and 5, you could put this in a script:\n\n```sqf\n_rand = random 6;\n_num = _rand - (_rand mod 1);\n```\n\nIn A1, the new commands round, floor or ceil would be the easier way to round."}]}