liveBook · Manning

Value

As explained in Modern C

A value is data that can be evaluated as a C condition, with zero representing false and any nonzero value representing true.

Consider `double x = 5.0; double y = 3.0; x = (x * 1.5) - y; printf("x is %g\n", x);`. C evaluates intermediate values—5.0, 7.5, 3.0, 4.5—then stores 4.5 in `x` and prints it. A value is abstract data that can be evaluated in a C condition: zero means false, while a nonzero value means true. section 5.1 section 5.1.1

   double x = 5.0;
   double y = 3.0;
   ...
   x = (x * 1.5) - y;
   printf("x is \%g\n", x);


!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":3},{\"line\":0,\"ch\":9}],[{\"line\":1,\"ch\":3},{\"line\":1,\"ch\":9}],[{\"line\":0,\"ch\":3},{\"line\":0,\"ch\":9}],[{\"line\":1,\"ch\":3},{\"line\":1,\"ch\":9}],[{\"line\":4,\"ch\":3},{\"line\":4,\"ch\":9}]]"}
!@%STYLE%@!

Trace the variables and intermediate results in the example from initialization through assignment and output. section 5.1

TAKEAWAY

  • Reason primarily about values rather than their machine representations; representations may vary across architectures and types. section 5.0
  • Treat every value as having a statically determined type, which determines permitted operations and their results. section 5.1.2
  • Distinguish values from data: execution data assembles the values held by all objects at a particular moment. section 5.1.1
  • Remember that unobserved intermediate results need not exist in the final executable when optimization preserves the observable result. section 5.1

Values are modeled as mathematical entities independent of a particular run, executable, or representation. C’s basic values are numbers or translate to numbers, although some types—such as characters, truth values, or floating-point values—serve roles beyond ordinary arithmetic. section 5.1.1 section 5.8

How Modern C covers it

How deep it goes
Defines values, types, representations, observability, and optimization, while deferring detailed type-specific behavior.
Examples
Uses floating-point assignment, arithmetic subexpressions, conditional zero behavior, and optimized `printf` code.
What you can do after
Evaluate C examples in terms of abstract values, types, observable effects, and portable behavior.
How it connects
Connects values with types, expressions, variables, data, the abstract state machine, and optimization.

Also explained in

Compare how 7 books explain value →

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.