Skip to main content
gamedev.net
🔒 Locked

MOD?!?!

Started by H4ck3r Dec 13, 2002 at 11:21 AM 2 replies 200+ views
Original Post
H4ck3r
H4ck3r
In visual basic you have a function "Mod". It works like this: 4 Mod 2 = 0 5 Mod 2 = 1 1000 Mod 16 = 8 In Visual c++, I cant find this function. I do use modf(), but that''s something different, ive noticed. So is there a Mod function in C++? What do i have to do? 10x, H4ck3r
Wildfire
Wildfire
What you''re looking for is the % operator

4 % 2 = 0
How do I set my laser printer n stun? o
NeonGE
NeonGE
In visual C you can use "%"

like this

4 % 2 = 0

If God with me, Who against me?
--------------------------------------------- If God with me, Who against me?Personal Web Samuel Prince Blog...
Zern
Zern
The modulus operator in C++ is %...

i.e.

int nResult = 0;
nResult = 5 % 2;


nResult will be 1... however % only works with ints ... if you need to work with floats look up the function ''fmod''.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.