liveBook · Manning

Arithmetic type

As explained in Modern C

An arithmetic type is a C type representing numeric values, including integer, floating-point, and complex types.

A mixed-sign comparison

-1 < 0 // true -1U < 0U // false -1 < 0U // false; dangerous mixed signedness The operands' types can silently change a value before comparison. These numeric C types are arithmetic types: integer, floating-point, and complex types. section 5.4

Arithmetic types represent numeric values, but combining them can trigger implicit conversions. Signed and unsigned operands are especially hazardous because a negative value may become a large unsigned value. section 5.4

TAKEAWAY

  • Avoid operations whose operands have different signedness. section 5.4
  • Choose arithmetic types so that implicit conversions remain harmless. section 5.4

How Modern C covers it

How deep it goes
Explains implicit-conversion consequences through comparisons, assignments, precision risks, and signedness recommendations.
Examples
Uses mixed-sign comparisons, integer assignments, and combinations of integers with floating-point or complex constants.
What you can do after
Evaluate arithmetic expressions and choose compatible types to reduce harmful implicit conversions.
How it connects
Connects arithmetic types with implicit conversions, signedness, integer types, floating-point types, and complex types.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.