IF argument order of operations
Mike G
Posts: 2,702
I'm curious about the order of evaluation in an IF statement. The snippet below is within an infinite loop. I'd rather not invoke the I2C bus, rtc.clockHour, on ever iteration, only if i == 100,000.
Given a logical AND, are the following two snippets equal? Will the condition return false if one of the conditions are false while not testing the other? Or are both conditions always tested?
repeat ... if(i++//100_000 == 0) if(rtc.clockHour == dhcpRenew) RenewDhcpLease i := 1
Given a logical AND, are the following two snippets equal? Will the condition return false if one of the conditions are false while not testing the other? Or are both conditions always tested?
if(i++//100_000 == 0 AND rtc.clockHour == dhcpRenew) RenewDhcpLease i := 1
if(rtc.clockHour == dhcpRenew AND i++//100_000 == 0) RenewDhcpLease i := 1
Comments
I should have prefaced with in Spin... My query stemmed from experience with other languages.
Thanks all