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. C#
  4. mod

mod

Scheduled Pinned Locked Moved C#
csharp
6 Posts 5 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.
  • T Offline
    T Offline
    TAREQ F ABUZUHRI
    wrote on last edited by
    #1

    i want the mod e.g. 2.6 mod = 6 4.0 mod =0 how can get this in C# ================= i want function to make this 2.6 =3 2.3 =3 2.1 =3 2.0 =2 is this function allready exist in C#

    Palestine

    L G L D 5 Replies Last reply
    0
    • T TAREQ F ABUZUHRI

      i want the mod e.g. 2.6 mod = 6 4.0 mod =0 how can get this in C# ================= i want function to make this 2.6 =3 2.3 =3 2.1 =3 2.0 =2 is this function allready exist in C#

      Palestine

      L Offline
      L Offline
      leckey 0
      wrote on last edited by
      #2

      Did you even try google or msdn?????:mad:

      _____________________________________________ Flea Market! It's just like...it's just like...A MINI-MALL!

      1 Reply Last reply
      0
      • T TAREQ F ABUZUHRI

        i want the mod e.g. 2.6 mod = 6 4.0 mod =0 how can get this in C# ================= i want function to make this 2.6 =3 2.3 =3 2.1 =3 2.0 =2 is this function allready exist in C#

        Palestine

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        The modulo operator in C# is %. However, the modulo operator doesn't do at all what you are asking for. Actually I'm not at all sure what you are actually asking for, but it's not modulo.

        TAREQ F ABUZUHRI wrote:

        2.6 mod = 6 4.0 mod =0

        That looks like the fraction part of a floating point number. You can do that by using the Math.IEEEReminder method: double num = 2.6; double fraction = Math.IEEEReminder(num, 1); // result is 0.6

        TAREQ F ABUZUHRI wrote:

        i want function to make this 2.6 =3 2.3 =3 2.1 =3 2.0 =2

        You have to explain what you mean by that, because it doesn't make any sense at all.

        --- single minded; short sighted; long gone;

        1 Reply Last reply
        0
        • T TAREQ F ABUZUHRI

          i want the mod e.g. 2.6 mod = 6 4.0 mod =0 how can get this in C# ================= i want function to make this 2.6 =3 2.3 =3 2.1 =3 2.0 =2 is this function allready exist in C#

          Palestine

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, I suggest you look into the Math class; it has what you need and more. The first can be done with 10.0*(floatValue % 1.0) or 10*IEEEremainder, but you should not call this mod, it is more like 10 times mod The second is a simple ceiling. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


          1 Reply Last reply
          0
          • T TAREQ F ABUZUHRI

            i want the mod e.g. 2.6 mod = 6 4.0 mod =0 how can get this in C# ================= i want function to make this 2.6 =3 2.3 =3 2.1 =3 2.0 =2 is this function allready exist in C#

            Palestine

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            TAREQ F ABUZUHRI wrote:

            =================

            Oh... Is that supposed to be some kind of separator, indicating that the text above it is a separate question from the text below it? I replied assuming that you were talking about the same question. That was far from obvious... Why not just write "and I have another qustion"?

            --- single minded; short sighted; long gone;

            1 Reply Last reply
            0
            • T TAREQ F ABUZUHRI

              i want the mod e.g. 2.6 mod = 6 4.0 mod =0 how can get this in C# ================= i want function to make this 2.6 =3 2.3 =3 2.1 =3 2.0 =2 is this function allready exist in C#

              Palestine

              D Offline
              D Offline
              dino2094
              wrote on last edited by
              #6

              For your "mod", double x; your_mod = x - (int)x ; For the second part, you want Math.Ceiling

              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