Question about MOD operator

Results 1 to 2 of 2

Thread: Question about MOD operator

  1. #1
    Join Date
    Dec 1969

    Default Question about MOD operator

    Hello,<BR><BR>I have a question about how the MOD operator works. It can best be summed up as such:<BR>Are these chunks of code synonymous?<BR><BR>&#039;chunk 1<BR>A=x mod 2<BR>If A &#060;&#062; 0 then<BR> &#039;there is a remainder<BR>end if<BR><BR>&#039;chunk 2<BR>If x mod 2 Then<BR> &#039;there is a remainder<BR>end if<BR><BR>Am I making sense? <BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default No, question about CBOOL...

    This hasn&#039;t really go anything to do with the MOD operator.<BR><BR>You could just as well ask if these two lines are equivalent:<BR><BR> If any_expression Then<BR>vs.<BR> If any_expression &#060;&#062; 0 Then<BR><BR>And the answer is "Yes," so long as the expression evaluates to a number.<BR><BR>Why? Because VBScript *insists* on seeing a boolean value between the words IF and THEN. If you have anything except a boolean value, then it tries to *convert* it to boolean. Exactly as if you had used CBOOL on the value.<BR><BR>That is,<BR> If any_expression Then<BR>is converted, automatically, using<BR> If CBOOL(any_expression) Then<BR><BR>But what do you think CBOOL does? Yep.<BR> CBOOL(0) --&#062;&#062; False<BR> CBOOL(any_non_zero_number) --&#062;&#062; True<BR><BR>So your two expressions are equivalent, but not because it has anything at all to do with MOD.<BR><BR><BR><BR>

Posting Permissions

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