easyforth icon indicating copy to clipboard operation
easyforth copied to clipboard

in index.markdown, need chg bitwise C ops & and | to && and ||

Open dashyr opened this issue 8 years ago • 3 comments

The first line is the equivalent of 3 < 4 & 20 < 30 in a C-based language. The second line is the equivalent of 3 < 4 | 20 > 30.

I believe that the bitwise operators above (& , |) should be changed to the logical operators (&& , ||) as below.

The first line is the equivalent of 3 < 4 && 20 < 30 in a C-based language. The second line is the equivalent of 3 < 4 || 20 > 30.

Thank you for making EasyForth.

dashyr avatar Mar 06 '17 08:03 dashyr

+1

PSLLSP avatar May 18 '18 02:05 PSLLSP

The operators are bitwise, so it only makes sense to equate them to bitwise operators in C.

temyurchenko avatar Nov 03 '19 20:11 temyurchenko

I believe that the bitwise operators above (& , |) should be changed to the logical operators (&& , ||)

In Forth, and, or, xor, invert are bitwise. So it's better to illustrate them with bitwise operators in C.

In the same time, a normalized true flag in Forth is represented by a single-cell value with all bits set. So, the words < and > return -1 on true, and the result of those expressions will be -1 in Forth, and 1 in C, regardless whether logic or bitwise operators are used in C.

ruv avatar May 11 '24 17:05 ruv