• 0 Posts
  • 5 Comments
Joined 3Y ago
cake
Cake day: Dec 20, 2021

help-circle
rss

IPv6 can run on IPv4 and look how much that helped


With performance optimizations seemingly having lost their relevance in an era of ever-increasing hardware performance

What a ridiculous assertion.


  • if square_root takes a uint64_t argument then it should return a uint32_t
  • x = (x + (s / x)) / 2; This update of the test value uses integer divisions which means it is not guaranteed to converge (due to the truncation moving your approximation further away than the previous iteration). You should also check that x > 0 to avoid accidental division by zero.
  • it looks like seed is trying to calculate pow(10, log_100(x)) in some way, but it has bugs, for example a < 10 is true for radicand values of 100-999, 10000-99999, 1000000-9999999 etc. which probably isn’t what you want. An easier way to estimate a starting value for the first iteration would be to take a number that has half as many bits as the input, since we know that if a number X uses K bits then its square root will use K/2 bits. You can use a method to calculate the position of the most significant set bit in the input and then use 2^(k/2) as the seed.
  • for ease of readability and checking correctness, I would recommend that you don’t use implicit casts to float for arithmetic and avoid implicit casts back to integers with the results. Declare floating point variables when you want floating point arithmetic and then use explicit casts back to ints to make it clear to the reader (reviewer) that any truncation of the result is intentional. This is considered good practice when writing C. You can compile with -Wall -Werror (with gcc) to enforce those checks and make them compile errors that you must fix.

O(N^2) - with every new character in the string its speed decreases exponentially,

Try to be precise when teaching others. O(N^2) increases “quadratically” not exponentially. O(k^N) would be exponentially increasing with N.


The best managers and team builders are people that aren’t afraid to get people in with skills far out pacing their own.

This is the most important thing when hiring. If staff only hire new employees that are less experienced/talented than themselves then the skill level of the team reduces over time. If you give hiring staff the target of finding someone better than they are, the skill of the team increases over time.