Type Conversion
Implicit conversions between types and explicit casts.
Easy
Mixing types converts to a common type: 5 / 2 is 2, but 5 / 2.0 is 2.5. Cast explicitly: (float)sum / n. Beware signed/unsigned comparisons: -1 < 1u is false.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.