a little confuse o_0???

This is a discussion on a little confuse o_0??? within the C++ Programming forums, part of the General Programming Boards category; For efficiency (if it matters), you could express it as NOT leap year if and only if (year mod 4 ...

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    For efficiency (if it matters), you could express it as NOT leap year if and only if

    (year mod 4 != 0) or ((year mod 100 == 0) and (year mod 400 != 0))

    This way, 3 years out of 4, it only executes the first test due to shortcutting. In most of the remaining cases, only the first and second tests execute, again due to shortcutting.
    Last edited by robatino; 01-24-2008 at 01:05 AM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PayPal confuse me
    By Akkernight in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 04-20-2009, 12:56 PM
  2. Simple Sorts Confuse ME =/
    By otchster in forum C Programming
    Replies: 5
    Last Post: 12-03-2005, 02:02 PM
  3. confuse about included files
    By C-Dumbie in forum C++ Programming
    Replies: 2
    Last Post: 12-31-2002, 07:04 PM
  4. confuse with character array
    By dv007 in forum C Programming
    Replies: 6
    Last Post: 08-09-2002, 02:05 PM
  5. Too confuse
    By dv007 in forum C++ Programming
    Replies: 6
    Last Post: 07-25-2002, 06:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21