Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Odd and Even numbers

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 423 Views
    Loading More Posts
    • 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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 07/06/2010 at 16:50, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11.5 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Is it possible to determine if an index is odd or even?

      ~Shawn

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 07/06/2010 at 17:02, xxxxxxxx wrote:

        Figured this out...  ended up using ...

        if (Modulo(i, 2) != 0)

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 08/06/2010 at 05:44, xxxxxxxx wrote:

          Don't do that if you're handling Integers and high volume, because Modulo is a Real function.

          Easier using the C++ modulo operator:

          if (i%2) {
          }

          Hope it helps!

          Kabe

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 08/06/2010 at 05:57, xxxxxxxx wrote:

            Please use LModulo() for integers.

            cheers,
            Matthias

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 08/06/2010 at 09:06, xxxxxxxx wrote:

              Anything wrong with the C++ operator?

              Kabe

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 08/06/2010 at 10:04, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                Anything wrong with the C++ operator?

                Kabe

                Nothing wrong, in fact LModulo just wraps % with a special condition if a<0.

                from c4d_tools.h

                  
                inline Real Modulo(Real a, Real b)  
                {  
                  if (b==0.0) return 0.0;  
                  LONG n = (LONG) (a/b);  
                  
                  a -= n*b;  
                  if (a<0.0) a+= b;  
                  
                  return a;  
                }  
                  
                inline LONG LModulo(LONG a, LONG b)  
                {  
                  if (!b) return 0;  
                  if (a >= 0) return a%b;  
                  
                  a -= (a/b)*b;  
                  if (a<0) a+= b;  
                  
                  return a;  
                }  
                  
                inline LLONG LModulo(LLONG a, LLONG b)  
                {  
                  if (!b) return 0;  
                  if (a >= 0) return a%b;  
                  
                  a -= (a/b)*b;  
                  if (a<0) a+= b;  
                  
                  return a;  
                }  
                

                cheers,
                Matthias

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post