Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Modulo ?

Reply
Thread Tools

Modulo ?

 
 
Zayd Connor
Guest
Posts: n/a
 
      03-19-2009
Maybe i need to get some sleep, but can someone explain how modulos
work?

Thanks
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
7stud --
Guest
Posts: n/a
 
      03-19-2009
Zayd Connor wrote:
> Maybe i need to get some sleep, but can someone explain how modulos
> work?
>
> Thanks


result = 7 % 3
puts result

--output:--
1

7 has two 3's in it, and after removing those two 3's from 7, the
remainder is 1.




--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Brian Adkins
Guest
Posts: n/a
 
      03-19-2009
Zayd Connor <(E-Mail Removed)> writes:

> Maybe i need to get some sleep, but can someone explain how modulos
> work?


From "Discrete Mathematics by Rosen":

"Let a be an integer and m be a positive integer. We denote by a mod m
the remainder when a is divided by m.

It follows from the definition of remainder that a mod m is the
integer r such that:

a = q * m + r and 0 <= r < m "

This is all assuming you didn't type an 'o' when you meant 'e'

--
Brian Adkins
http://lojic.com/
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      03-19-2009
On 19.03.2009 06:50, Zayd Connor wrote:
> Maybe i need to get some sleep, but can someone explain how modulos
> work?


http://lmgtfy.com/?q=modulo
 
Reply With Quote
 
Rob Biedenharn
Guest
Posts: n/a
 
      03-19-2009
On Mar 19, 2009, at 10:22 AM, Robert Klemme wrote:

> On 19.03.2009 06:50, Zayd Connor wrote:
>> Maybe i need to get some sleep, but can someone explain how modulos
>> work?

>
> http://lmgtfy.com/?q=modulo
>



This seems completely unnecessary. There was already a great response
from Brian who not only directly addressed the "modulos", but also
picked up and pointed out (subtly) that the question might have been
about "modules". Something that makes perfect sense, but I certainly
didn't see that possibility.

And did you Google modulo or module yourself to see how useful the
result really is? If you're going to simply shout lmgtfy, at least put
"ruby" in there, too (well, for module, not for modulo

-Rob

Rob Biedenharn http://agileconsultingllc.com
http://www.velocityreviews.com/forums/(E-Mail Removed)



 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      03-19-2009
On 19.03.2009 15:40, Rob Biedenharn wrote:
> And did you Google modulo or module yourself to see how useful the
> result really is?


I did.

robert

 
Reply With Quote
 
Zayd Connor
Guest
Posts: n/a
 
      03-19-2009
Rob Biedenharn wrote:
> On Mar 19, 2009, at 10:22 AM, Robert Klemme wrote:
>
>> On 19.03.2009 06:50, Zayd Connor wrote:
>>> Maybe i need to get some sleep, but can someone explain how modulos
>>> work?

>>
>> http://lmgtfy.com/?q=modulo
>>

>
>
> This seems completely unnecessary. There was already a great response
> from Brian who not only directly addressed the "modulos", but also
> picked up and pointed out (subtly) that the question might have been
> about "modules". Something that makes perfect sense, but I certainly
> didn't see that possibility.
>
> And did you Google modulo or module yourself to see how useful the
> result really is? If you're going to simply shout lmgtfy, at least put
> "ruby" in there, too (well, for module, not for modulo
>
> -Rob
>
> Rob Biedenharn http://agileconsultingllc.com
> (E-Mail Removed)


Thanks guys,(singing) I can see clearly now the rain is gone . Maybe I
should have been more clear and added the % sign when mentioning modulo,
so I wouldn't confuse anyone thinking I meant modules

Thanks

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Michael Malone
Guest
Posts: n/a
 
      03-19-2009

> Thanks guys,(singing) I can see clearly now the rain is gone . Maybe I
> should have been more clear and added the % sign when mentioning modulo,
> so I wouldn't confuse anyone thinking I meant modules
>
> Thanks
>
>

Though there is one thing I would like to point out: 0 % 7 = 0
So 'remainder' is not strictly true

Michael


================================================== =====================
This email, including any attachments, is only for the intended
addressee. It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
================================================== =====================


 
Reply With Quote
 
Sebastian Hungerecker
Guest
Posts: n/a
 
      03-19-2009
Michael Malone wrote:
> Though there is one thing I would like to point out: 0 % 7 = 0
> So 'remainder' is not strictly true


Sorry I don't follow you. What's the remainder of 0/7 if not 0?
0-7*0 is 0, is it not?

Confused,
Sebastian

 
Reply With Quote
 
Michael Malone
Guest
Posts: n/a
 
      03-19-2009
Sebastian Hungerecker wrote:
> Michael Malone wrote:
>
>> Though there is one thing I would like to point out: 0 % 7 = 0
>> So 'remainder' is not strictly true
>>

>
> Sorry I don't follow you. What's the remainder of 0/7 if not 0?
> 0-7*0 is 0, is it not?
>
> Confused,
> Sebastian
>
>

Many people I know and work with simplify the modulo operator to
themselves as remainder, so mentally (whether or not it is correct)
assume 0/7 = 0 r 7
I am just making an explicit example of this not necessarily obvious
case. It's totally fine when one knows the semantics of modulo, it's
the simplification to remainder that many people make that causes
problems here.

Michael

================================================== =====================
This email, including any attachments, is only for the intended
addressee. It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
================================================== =====================


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[xsl] sort & modulo Tjerk Wolterink XML 3 04-22-2005 12:49 PM
Java ME modulo method ?? 900390d@acadiau.ca Java 1 05-19-2004 11:56 PM
Fast Division/Modulo Operation silentlights C Programming 8 04-23-2004 12:21 PM
Problems using modulo Griff Python 5 04-20-2004 12:20 PM
General modulo-question Christian Kruggel Java 1 07-07-2003 05:44 PM



Advertisments