Ad
  • Custom User Avatar

    While this is clever, I wouldn't consider it a best practice. It extends the range of allowed inputs to values whose cubes exceed the range that can be represented by the output type

  • Custom User Avatar

    / 2 better conveys the intent, though. I'd recommend writing clear and idiomatic code—it's more readable for humans, and clearly identifiable patterns are also easier for the compiler to optimize.

    Additionally, bit shifts are easy to misuse: for instance, if the left-hand operand is negative, the behavior of a right shift is implementation-defined