13 votes
Accepted

C function to read only numeric values

Definition of function main The definition of the function main should start with ...
Andreas Wenzel's user avatar
7 votes

Identify distance degeneracies on square and hexagonal lattices

The core algorithm is this: ...
Cris Luengo's user avatar
  • 5,573
6 votes

Computing the square root of a 64-bit integer

Your code is OK for prime sieving. If the rounding mode is nearest-ties-to-even and std::sqrt is correctly rounded (as required by IEEE 754), your code returns \$\...
Řrřola's user avatar
  • 161
5 votes
Accepted

Calculate the cost of Biryani lessons

Your code is concise, readable, and idiomatic. It works as you intended. It's small but nice snippet of code. You could probably turn it into a one-liner, but it would get rather complex and ...
gazoh's user avatar
  • 3,249
4 votes

C function to read only numeric values

Late to the review Why 10 in char num[10];? If trying to accommodate all 32-bit int, including ...
chux - Reinstate Monica's user avatar
3 votes

SortedIntSet: a set of integers that can be iterated in ascending order in O(N) time

I am a year late reviewing this, but what the heck. I overall like your SortedIntSet (I will have a few suggestions as to how it might be improved). To paraphrase ...
Booboo's user avatar
  • 1,636
3 votes

C function to read only numeric values

<ctype.h> functions accept int The functions in <ctype.h>, such as ...
Toby Speight's user avatar
  • 74.9k
2 votes
Accepted

Any amount bits integer

You forgot std:: Types like uint8_t from <cstdint> are defined in the ...
G. Sliepen's user avatar
  • 55.4k
2 votes
Accepted

C++ Arbitrary Precision Whole Number Class

Interface I think the constructor that can be invoked with a std::string should be explicit. We should have implicit conversion ...
Toby Speight's user avatar
  • 74.9k
2 votes

Fastest (in clock cycles) 16-bit x 16-bit unsigned integer division algorithm for ATMEGA1284?

I don't know if this is going to be useful to OP, but it may be useful to others. At first, I thought actually normalising the numerator/denominator would be a terrible idea. But it turned out to be ...
user8494560980's user avatar
1 vote

uint24_t implementation ported to Windows

Write proper C++ Your code uses lots of C-isms: it #includes C headers files and it uses printf(). Instead, write proper C++ ...
G. Sliepen's user avatar
  • 55.4k
1 vote

Register "%b" conversion specifier

The example code at https://man7.org/linux/man-pages/man3/printf_va_arg_function.3type.html may have some ways to optimize the conversion process.
theSparky's user avatar
  • 111
1 vote

Computing the square root of a 64-bit integer

An alterative to risking floating point issues is to perform an integer based square root: C based code ...
chux - Reinstate Monica's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible