When is this possible, if the programmer always uses <, not <=?

Consider two declarations for the loop:

for (int i = 0; i < 70; ++i)

and

for (int i = 0; i <= 69; ++i)

I assume the second will do 139 full comparisons, not 69. Is my assumption correct? I am not an electrical engineer, so I don’t know how ALU works, regardless of whether it makes the “less than or equal to” thingamabob in one fell swoop or what.

Can you give an example of use <=?

By the way, I'm trying to become a "hardcore" programmer like you guys.

+4
source share
5 answers

There is no right or wrong answer.

. <, <=. >!

, ! && || ...

! !

!

... !


.

9 < 10 || 9 == 10

1 , .

, <= .

+5

'<' '< =', .

, 70 69 .

, 70, 70 .

, 1 :

for i = 1, i <= 70

0:

for i = 0, i < 70
+3

. , 70.

. for-loop, , , .

, if.

< <= - . , , .

, , . .

: , , ? , , " ". < <=. , . .

0

, <= < . <= <.

0

, for (int i = 0; i < 70; ++i) , - , , 70 ( 0 69 ).

0
source

Source: https://habr.com/ru/post/1535692/


All Articles