Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Modulus operator

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Ax3l
Cheater
Reputation: 1

Joined: 22 May 2011
Posts: 37

PostPosted: Sun Jun 19, 2011 7:31 am    Post subject: Modulus operator Reply with quote

Hey , I really want to know what the modulus operator is, because I tried to understand this months before , and after hours I still dont' know

I googled and it says the modulus operator returns the remainder of division of a number by another one.

but I don't get it , I tried alot in C++

Code:
    int a=2,b=3,c;
    c= a%b;


it returns 2

but how ? 2 /3 = 0.6666 or 1

when I assigned 100 to a it returned 1

again I don't understand , 100/3 = 33

EDIT : Never mind I GET IT Smile

100/3 = 33
33*3 =99
100-99 =1

something like that Very Happy
Back to top
View user's profile Send private message MSN Messenger
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Sun Jun 19, 2011 8:52 am    Post subject: This post has 1 review(s) Reply with quote

When two is divided by three, three cannot go into two even once. Therefore, the remainder is two.
Back to top
View user's profile Send private message
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Mon Jun 20, 2011 11:36 am    Post subject: Reply with quote

@OP it rounds up, 100 / 3 is 33.3333333333333333 the .33333333333333 rounded to 1 is the modulous of 100 / 3.
_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 383

Joined: 09 May 2003
Posts: 22897
Location: The netherlands

PostPosted: Mon Jun 20, 2011 12:37 pm    Post subject: Reply with quote

100 % 6 = 4
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Ax3l
Cheater
Reputation: 1

Joined: 22 May 2011
Posts: 37

PostPosted: Mon Jun 20, 2011 1:33 pm    Post subject: Reply with quote

AhMunRa wrote:
@OP it rounds up, 100 / 3 is 33.3333333333333333 the .33333333333333 rounded to 1 is the modulous of 100 / 3.


Doesn't it round down ?

100/3 = 33.3333333
34*3 = 102

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 383

Joined: 09 May 2003
Posts: 22897
Location: The netherlands

PostPosted: Mon Jun 20, 2011 1:55 pm    Post subject: Reply with quote

you had it correct in the first posts. Modulus is what is left after being divided by the given value
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
lucidity
Advanced Cheater
Reputation: 0

Joined: 16 Feb 2011
Posts: 91

PostPosted: Mon Jun 20, 2011 1:56 pm    Post subject: Reply with quote

Modulus is not simply rounding the decimal portion of the quotient up, consider:

200 / 3 = 66.66666666666
Remainder is 0.6666666666, rounded up is 1
200 - 1 = 199
199 / 3 = 66.33333333333, which is incorrect

Modulus is truncated rounding of the quotient and returning the remainder:
200 / 3 = 66.66666666666
Truncating the quotient, you get 66.
200 - (3 * 66) = 2
200 - 2 = 198
198 / 3 = 66, which is correct

_________________
Antec Twelve Hundred Full Tower EVGA E760 CLASSIFIED EVGA GeForce GTX 580 SuperClocked 1536MB i7-980XE CORSAIR DOMINATOR 6GB PC3 12800 DDR3 OS: Intel X25-M SSD Game Storage: Raid-0 2 x WD VelociRaptor 10000 RPM CE Cache Drive: 500GB WD Caviar Power Supply: OCZ Z Series Gold 1000W
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites