Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion exercises/practice/grains/.approaches/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ uint64_t square(uint8_t index)

uint64_t total(void)
{
return ((((uint64_t)1 << 63) - 1) << 1) + 1;
// '~' is the NOT bitwise operator in C
// By flipping all bits of 0 in a uint64_t container (000...0 -> 111...1)
// Can you guess what it returns?
return ~0ULL;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Came to say this. Doing this correctly is more involved than the current solution (and the sample solution provided is not meant to be "optimal", just good).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanplusplus This is a PR for the "Bit-shifting" approach in the "Dig Deeper" section that Bobahop wrote (https://exercism.org/tracks/c/exercises/grains/dig_deeper), not the example solution.

Comment on lines +50 to +53
}
```

Expand Down
Loading