The Mod function

Post your coding questions such as 'how to' here.
Post Reply
Mr. O
Newcomer
Posts: 32
Joined: Thu Nov 15, 2007 4:10 am
Location: United States

The Mod function

Post by Mr. O »

I am having trouble with the mod function. I tried several variations to try to get the function to work but it wont. The problem is probably a stupid one so if anyone can help I would very much appreciate it!

Thanks in advance
Mr. O
User avatar
Ilmuri
Developer
Developer
Posts: 277
Joined: Sun Aug 26, 2007 2:46 pm
Location: \o

Re: The Mod function

Post by Ilmuri »

How is it not working?
CoolBasic henkilökuntaa
Kehittäjä
CoolBasic Classic
User avatar
valscion
Moderator
Moderator
Posts: 1599
Joined: Thu Dec 06, 2007 7:46 pm
Location: Espoo
Contact:

Re: The Mod function

Post by valscion »

It might be hard to understand how Mod works, becouse you don't use it as a function or a command, you use it as an operator. Here's an example:

Code: Select all

Text 0, 0, Str( 5 Mod 2 ) 'prints 1
Text 0, 13, Str( 6 Mod 4 ) 'prints 2
Text 0, 26, Str( 13 Mod 3 ) 'prints 1
Text 0, 39, Str( 42 Mod 7 ) 'prints 0
DrawScreen
WaitKey
So basically, the syntax is:

Code: Select all

DIVIDEND Mod DIVISOR
I hope this solves your problem :)
cbEnchanted, uudelleenkirjoitettu runtime. Uusin versio: 0.4.1 — Nyt myös sorsat GitHubissa!
NetMatch - se kunnon nettimättö-deathmatch! Avoimella lähdekoodilla varustettu
vesalaakso.com
Post Reply