Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. MOD Operator

MOD Operator

Scheduled Pinned Locked Moved Visual Basic
testingbeta-testinghelpquestionlounge
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    codemunkeh
    wrote on last edited by
    #1

    OK, there doesn't seem to be a concise definition of this anywhere, particularly on MS's pathetic excuse for help. With the Mod operator, I've always thought that it return everything after the decimal point. Eg, 12 / 5 = 2.4 Therefore I'd expect 12 Mod 5 = 4 In practice, the result seems to be a random number, dependant on the current temparature in Kelvin, the number of times you have double clicked in the last six seconds and a random number between 12 and 47. From some testing... 12 Mod 5 = 2 ?? :mad: In fact, from the source code on MSDN, they say that 10 Mod 3 = 1 All I really need it for is working out if a Byte is even or not. If anyone can dare to explain, I'm sure it'll be useful.


    Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

    D T 2 Replies Last reply
    0
    • C codemunkeh

      OK, there doesn't seem to be a concise definition of this anywhere, particularly on MS's pathetic excuse for help. With the Mod operator, I've always thought that it return everything after the decimal point. Eg, 12 / 5 = 2.4 Therefore I'd expect 12 Mod 5 = 4 In practice, the result seems to be a random number, dependant on the current temparature in Kelvin, the number of times you have double clicked in the last six seconds and a random number between 12 and 47. From some testing... 12 Mod 5 = 2 ?? :mad: In fact, from the source code on MSDN, they say that 10 Mod 3 = 1 All I really need it for is working out if a Byte is even or not. If anyone can dare to explain, I'm sure it'll be useful.


      Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

      D Offline
      D Offline
      Don Trainer
      wrote on last edited by
      #2

      MOD Returns the remainder left over after the first number is divided by the second number 12/5 is 2 with a remainder of 2 Therefore 12 MOD 5 is 2 10/3 is 3 with a remainder of 1 Therefore 10 MOD 3 is 1 and so forth. Don

      C 1 Reply Last reply
      0
      • D Don Trainer

        MOD Returns the remainder left over after the first number is divided by the second number 12/5 is 2 with a remainder of 2 Therefore 12 MOD 5 is 2 10/3 is 3 with a remainder of 1 Therefore 10 MOD 3 is 1 and so forth. Don

        C Offline
        C Offline
        codemunkeh
        wrote on last edited by
        #3

        So it's the actual difference...dang. Been thinking in decimal too long. Well that was clever - especially since it's only taken me 3 years to notice... Ooo...this could have new uses. Thanks muchly.


        Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

        D 1 Reply Last reply
        0
        • C codemunkeh

          So it's the actual difference...dang. Been thinking in decimal too long. Well that was clever - especially since it's only taken me 3 years to notice... Ooo...this could have new uses. Thanks muchly.


          Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

          D Offline
          D Offline
          Don Trainer
          wrote on last edited by
          #4

          Yuppers such as a quick and dirty way to check to see if the current minute is a multiple of 5 without all the fancy if minute/5 = int(minute/5) and so forth. Use it for all sorts of cool stuff. Glad to be of help...

          1 Reply Last reply
          0
          • C codemunkeh

            OK, there doesn't seem to be a concise definition of this anywhere, particularly on MS's pathetic excuse for help. With the Mod operator, I've always thought that it return everything after the decimal point. Eg, 12 / 5 = 2.4 Therefore I'd expect 12 Mod 5 = 4 In practice, the result seems to be a random number, dependant on the current temparature in Kelvin, the number of times you have double clicked in the last six seconds and a random number between 12 and 47. From some testing... 12 Mod 5 = 2 ?? :mad: In fact, from the source code on MSDN, they say that 10 Mod 3 = 1 All I really need it for is working out if a Byte is even or not. If anyone can dare to explain, I'm sure it'll be useful.


            Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

            T Offline
            T Offline
            TwoFaced
            wrote on last edited by
            #5

            The documentation says it computes the remainder. http://en.wikipedia.org/wiki/Remainder[^] Seems like the documentation was spot on to me :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups