42ยทmindgap / CPP02 ยท lab
๐Ÿ“ handbook โฏ tracer

Bits / what a Fixed actually stores

Type a number the way you would write it as a literal. The lab runs the same arithmetic as Fixed(const float), then reads the result back the three ways the class offers. Every step is shown, nothing is hidden behind the word โ€œapproximatelyโ€.

input the literal you would write

presets
step the raw value the way -- and ++ do

encode Fixed(const float value)

    the object one int, interpreted

    sign23 whole bits8 fraction bits

    decode three views of the same raw value

      what happened to your number quantization

      Overload / which function does the compiler pick

      Pick an argument and watch overload resolution run against the four Fixed constructors. Every outcome in this table was compiled and run on this machine. Then flip the constness of two objects and see which max answers.

      constructor call Fixed x( argument );

      static call Fixed::max( a, b )

      stream insertion why the parameter is const Fixed &

      A plain Fixed & parameter would refuse two of the three things the subject's mains actually print. const Fixed & binds all three, and costs no copy.

      Multiply / why the raw product cannot be used

      Two numbers, two ways to multiply them. The integer form is exact and dies at 182. The float form survives to the type's own limit. Both are computed here exactly as the C++ would compute them, including the 32 bit wrap and the float rounding.

      operands a ร— b

      ร— presets

      integer form (_value * other._value) / 256

        float form Fixed(toFloat() * other.toFloat())

          verdict

          bsp / drag the point, read the three signs

          Drag the cyan point, or the three vertices. Coordinates are quantized to 1/256 the moment a Point is built, so the lab shows both what you asked for and what the class stored. The three cross products are computed with the same operators bsp uses.

          the point requested versus stored

          the three edges cross(o, a, point)

          how each cross product was computed same operators as the code