Results 1 to 2 of 2

Thread: .Net & C# question

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default .Net & C# question

    Hi, I need in a loop to rest of division; which one is more efficient?
    Qt Code:
    1. for (i =0; .....i++) {
    2. //int r;
    3. //Math.DivRem(i+1, 2, out r);
    4. int r = (i + 1) % 2;
    5. if ( r == 0) return i;
    6. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: .Net & C# question

    According to the docs DivRem() calculated both the quotient and remainder.

    If you need only the remainder use %, as division is the most time consuming from all of the basic arithmetic operators.

Similar Threads

  1. Add custom QTreeView in VS .NET
    By wind in forum Newbie
    Replies: 4
    Last Post: 5th October 2006, 18:04
  2. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 15:38
  3. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 22:41
  4. Qt and .NET
    By Brandybuck in forum Qt Programming
    Replies: 6
    Last Post: 6th July 2006, 02:01
  5. xml with binary question
    By TheKedge in forum Qt Programming
    Replies: 7
    Last Post: 13th January 2006, 00:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.