CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2014

    math or if statement


    I at some point in my past was advised that sometimes using math to determine a thing was better than the actually logic, because the processing was shorter.

    I don't remember what it was referring to, for, or if, or some sort of high-level shorthand

    However, since then, I've been using math or mod instead of if's from time to time,

    is that actually faster?
    will the average future coder understand my use of mod?

    eg, is it better to say:

    for i from 0 to 10
    whatever = i mod 5


    for i from 0 to 10
    if i < 5
    whatever = i
    whatever = i - 5

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    Re: math or if statement

    If you use something that you feel that others won't find clear, add a comment.

  3. #3
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: math or if statement

    Neither one. They don't compile without End If.

    Also, you don't use 'whatever'

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.