-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Thanks for this awesome book. It's been my go to reference for all things Rcpp. One thing that I think that could be clarified though is the section on logical operators (chapter 11). Coming from an R background, I expected & and | to take and return logical values, but my code wasn't working. After a bit of digging, I learned it was because && and || are the logical operators in C++ while & and | are bitwise (1 is interpreted as TRUE and everything else is interpreted as FALSE).
Most people from an R background would probably be looking for the logical operators so a clarification and a table like this could be useful.
| Operator | Symbol | Form | Operation |
|---|---|---|---|
| Logical NOT | ! |
!x |
true if x is false, or false if x is true |
| Logical AND | && |
x && y |
true if both x and y are true, false otherwise |
| Logical OR | || |
x || y |
true if either x or y are true, false otherwise |
Logical Operators in C++ (Source: learnCpp.com)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels