Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 4 mod 6 = 4? 4 mod 8 = 4?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
person




PostPosted: Mon Jan 31, 2005 2:30 pm   Post subject: 4 mod 6 = 4? 4 mod 8 = 4?

4 mod 6 = 4? 4 mod 8 = 4?
y does this happen?
i though mod returned a remainder
Sponsor
Sponsor
Sponsor
sponsor
md




PostPosted: Mon Jan 31, 2005 3:09 pm   Post subject: (No subject)

er... perhaps because you are trying to get the remainder when 4 is divided by 6... which just so happens to be 4 as 4 is not divisible by 6... The same is true for 4 mod 8. If you are trying to get the remainder when 8 is divided by four then you should be using 8 mod 4.

If you still don't understand what's going on (and this isn't much of a description i must admit...) then I would recoment the ever helpful google.
basketball4ever




PostPosted: Mon Jan 31, 2005 3:12 pm   Post subject: (No subject)

do you understand mod???

mod finds you the remainder...

since 4 isn't dividisble by 6 or 8... the remainder is going to be 4... its simple math. Confused
person




PostPosted: Mon Jan 31, 2005 3:14 pm   Post subject: (No subject)

Quote:
er... perhaps because you are trying to get the remainder when 4 is divided by 6... which just so happens to be 4 as 4 is not divisible by 6... The same is true for 4 mod 8. If you are trying to get the remainder when 8 is divided by four then you should be using 8 mod 4.


thanx, i get it now
typon




PostPosted: Mon Jan 31, 2005 3:22 pm   Post subject: (No subject)

yea got it ~!~!~!
4 mod [anything greater than 4] = 4

its the other way around if you want to find the remainder. xD
Viper




PostPosted: Sat Feb 05, 2005 1:26 pm   Post subject: (No subject)

if your jus trying to divide its probably easier to us div (not recommended for int)
Bacchus




PostPosted: Sat Feb 05, 2005 3:11 pm   Post subject: (No subject)

div works with int and it probably the best to use cause it rounds it to closes integer, / on the other hand doesnt
Cervantes




PostPosted: Sun Feb 06, 2005 9:00 am   Post subject: (No subject)

Bacchus wrote:
div works with int and it probably the best to use cause it rounds it to closes integer, / on the other hand doesnt

Careful:
Turing Help Reference wrote:

The div operator divides one number by another and produces the integer result, truncated in the direction of zero. For example, 7 div 2 produces 3 and -7 div 2 produces -3.


Turing:

put 5 / 3
put 5 div 3
Sponsor
Sponsor
Sponsor
sponsor
Bacchus




PostPosted: Sun Feb 06, 2005 9:28 am   Post subject: (No subject)

ok so it rounds down Razz
bugzpodder




PostPosted: Sun Feb 06, 2005 11:02 am   Post subject: (No subject)

whats

Quote:

5 mod -2
-5 mod -2
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: