Sitonce
Country: US
Show exams for United States Hong Kong
Sign in

Data Representation: TExES Computer Science 8-12 241

Updated 11 min read
Key takeaway

A bit pattern has meaning only under a representation rule.

  • For TExES Computer Science 8-12 (241), practice binary and hexadecimal conversion, distinguish integer, floating-point, character, string, and Boolean types, and make any fixed-width assumption explicit.
  • The same bits can represent different values, while some decimal fractions cannot be stored exactly in binary floating point.
On this page13 sections
  1. Bits, bytes, and interpretation
  2. Convert binary to decimal by place value
  3. Fixed width and overflow
  4. Signed values need a stated convention
  5. Integer, floating-point, character, and Boolean types
  6. Why some decimal fractions are approximate
  7. Rounding, truncation, and division are not the same
  8. Text encodings and file formats
  9. Arrays, dimensions, and memory reasoning
  10. Trace a representation question step by step
  11. Distinguish value, type, and display
  12. Frequent misconceptions
  13. How this topic fits the 241 framework

The official Computer Science 8-12 framework includes number-base systems, standard data types, constants and variables, arrays, input and output, and differences among primitive and referenced data. This guide builds those topics from original examples and identifies where a language-specific rule applies. A key idea is simple but powerful: bits are physical or logical states; interpretation comes from an agreed representation.

Bits, bytes, and interpretation

A bit has two possible states, often written 0 and 1. A group of bits can encode a number, a character, part of an image, or an instruction. The bit pattern alone does not tell you which meaning was intended. A type, format, protocol, or file specification supplies that interpretation. The eight-bit pattern 01011010 can be read as an unsigned binary integer, a character code under a particular encoding, or data inside a larger format.

A byte is commonly eight bits in the computer-science contexts covered here. An unsigned eight-bit value can express 2 to the power of 8, or 256, distinct patterns, from 00000000 through 11111111. Under the unsigned base-two interpretation, those correspond to values 0 through 255. A different representation may use those same patterns for a signed value, part of a color, or something else. Always read the stated type and width.

Convert binary to decimal by place value

Binary is base two. Each position represents a power of two, increasing from right to left: 1, 2, 4, 8, 16, and so on. For 01011010, add the place values with a 1: 64 + 16 + 8 + 2 = 90. A zero contributes nothing. To convert a nonnegative decimal integer into binary, repeatedly divide by two and read the remainders in reverse order, or decompose it into powers of two.

Hexadecimal is base sixteen and provides a compact way to write binary values. Its digits are 0 through 9 and A through F, where A represents ten and F represents fifteen. One hexadecimal digit corresponds to four bits because 16 equals 2 to the fourth power. Thus hexadecimal 5A maps to binary 0101 1010 and decimal 90. Grouping binary digits into nibbles from the right makes conversion easier.

Binary groupHex digitDecimal value
000000
100199
1010A10
1100C12
1111F15

Fixed width and overflow

A fixed-width unsigned representation has a limited range. With eight bits, the largest value is 255. Mathematically, 255 + 1 is 256, which needs a ninth binary digit. A system constrained to eight bits cannot represent that result in the same unsigned format. What happens next depends on the representation and language rules: an implementation might report an error, use a wider type, or define a wraparound behavior. Do not claim every language wraps identically.

This distinction matters when a problem gives a fixed width. Treat the width as part of the model and follow the specified overflow policy. Python integers, by contrast, have arbitrary precision subject to practical resource limits, so Python’s integer 255 plus 1 evaluates to 256. That Python behavior should not be confused with a declared eight-bit unsigned storage model.

Signed values need a stated convention

Computers can represent signed integers using different conventions. A question may specify a width and a particular scheme, or it may expect a language’s documented integer type. Do not infer the signed range from the bit pattern without knowing the convention. For this reason, separate a base conversion problem from a signed-encoding problem: first identify the representation, then decode it.

For example, the eight-bit pattern 11111111 means 255 when interpreted as unsigned binary. It would mean something else under a signed representation. If an item asks about two’s-complement conversion, use the exact width and method stated by the framework or question. Avoid importing a signed convention into a prompt that only specifies an unsigned byte.

Integer, floating-point, character, and Boolean types

An integer type represents whole-number values under its language and storage rules. Floating-point types approximate a broad range of real-number values using finite binary representations. A character type stores a character code or code unit under a defined encoding scheme. A string is a sequence of text units, though how Unicode text is encoded in memory depends on the language and implementation. A Boolean type represents logical truth values, commonly true and false.

Types affect operations. Adding two integers, concatenating two strings, and combining two Boolean conditions are different operations even if the language uses a plus sign for more than one purpose. Type conversion can change a value or its representation. In Python, int applied to a floating-point value truncates toward zero; this is a language-specific rule, not a universal conversion rule.

Primitive and reference types also differ conceptually. A primitive value typically holds the value directly according to a language’s model, while a reference provides access to an object or data structure elsewhere. Exact behavior varies by language. For tracing, determine whether an assignment copies a value or causes two names to refer to mutable shared data according to that language. Mutating a shared object can be visible through more than one reference.

Why some decimal fractions are approximate

Binary fractions use negative powers of two. The binary fraction 0.11 base two equals one-half plus one-quarter, or 0.75 in decimal, exactly. But a decimal fraction such as one-tenth has a repeating expansion in base two. A finite floating-point format cannot store every repeating expansion exactly, so the stored value is a nearby representable approximation.

This does not mean all decimal values are inexact or that floating-point calculations are useless. Some values, including many powers of one-half, have finite binary representations. Other values are represented with bounded precision, and a sequence of operations can accumulate rounding effects. The size of the error depends on the data type and computation. Use a numeric representation suited to the task, and do not treat display formatting as a change to the underlying stored value.

If a Python program prints a floating-point value with two decimal places, formatting controls the displayed text; it does not generally convert the internal number into exact decimal arithmetic. When approximate values are compared, a tolerance may be appropriate, depending on the application. For money or exact decimal rules, choose an appropriate decimal type or integer minor units when the requirements call for it. No single representation is correct for every problem.

Rounding, truncation, and division are not the same

Rounding selects a nearby value under a specified rule. Truncation discards a fractional part toward zero in Python’s int conversion. Floor chooses the greatest integer no larger than the value. For positive numbers these may look similar, but negative values expose the difference: Python -7 // 3 is -3 because floor division moves down, while int(-7 / 3) is -2 because conversion truncates toward zero. State the language and operation before explaining a result.

Integer division and modulo are also related through language-defined arithmetic identities, but the sign convention for negative operands can vary among languages. A safe trace follows the exact operator documentation for the language in the question. If a problem only needs nonnegative values, note that assumption rather than claiming a universal result for signed operands.

Text encodings and file formats

Text becomes data through an encoding that maps characters to numeric code points or code units and then to bytes. ASCII is a limited historical character set; Unicode defines a much broader repertoire, and UTF-8 is one encoding form for representing Unicode text. A byte sequence should not be decoded under an arbitrary encoding and assumed to produce the intended characters. The file format or communication protocol specifies how to interpret it.

The same principle applies to images, sound, video, and structured documents. A file extension can suggest a format but does not prove that the contents match it. Metadata, compression, bit depth, color model, and encoding can influence interpretation. When a question asks why a file displays incorrectly across software, consider format compatibility and encoding before assuming the bits themselves are damaged.

Arrays, dimensions, and memory reasoning

An array stores a sequence of elements accessible by index in languages that provide array indexing. A one-dimensional array can be pictured as a row; a two-dimensional array as rows and columns. If an array has r rows and c columns, the total number of elements is r times c. Index origin and valid boundary rules are language-specific. Python indexes sequences from zero and excludes the upper endpoint in slices, while other languages may use different conventions.

When estimating storage, state the element type and representation size. A fixed-size array of n elements each occupying b bytes would require n times b bytes for the element storage, before considering metadata, alignment, or implementation overhead. Do not assume every high-level list uses exactly the number of bytes implied by its values. The exam concept is the relationship between data structures and representation, not a vendor-specific memory layout unless specified.

Trace a representation question step by step

  1. Identify the stated type, base, width, encoding, and signedness.
  2. Translate each digit or bit using the correct positional weights.
  3. For text, identify the character encoding or code-point convention.
  4. Check whether a conversion, overflow, rounding, or truncation operation occurs.
  5. Keep mathematical value distinct from stored representation and displayed formatting.
  6. State any assumption that the question leaves unspecified.

For the unsigned byte 01011010, the place-value calculation produces 90. If it is later displayed as the character associated with the code point 90 in a specified encoding, that is a second interpretation step. The number is not inherently a letter. This separation between bits, numeric values, and encoded characters helps avoid answers that confuse a byte’s decimal value with its textual meaning.

Distinguish value, type, and display

Three layers can appear in a single code question: the mathematical value, the type that constrains operations, and the display format used to show a result. The integer value 90 could be printed in decimal as 90, in hexadecimal as 5A, or in binary as 01011010. Those displays differ while the represented unsigned value remains the same. If the type is a fixed-width byte, storage constraints add another rule; if it is an unbounded language integer, they may not.

A type conversion may preserve a value, approximate it, or discard information. Converting a floating-point value to an integer can lose its fractional portion. Converting a large integer to a narrower fixed-width type can fail or alter the result under the applicable rules. Converting text to a number can fail if the text does not follow the expected syntax. Ask what happens to the value at each conversion boundary instead of assuming that a new label merely changes display.

Frequent misconceptions

  • Assuming a bit pattern has only one possible meaning.
  • Decoding an integer without checking base, width, signedness, and type.
  • Assuming every eight-bit value is an unsigned integer from 0 to 255.
  • Claiming all decimal fractions are inexact in binary.
  • Treating printed formatting as a change to the stored floating-point value.
  • Assuming Python integers have the same overflow behavior as a fixed-width byte.
  • Calling truncation, floor, and rounding the same operation.
  • Assuming a string, character, and byte are interchangeable units.

How this topic fits the 241 framework

Competency 007 includes number-base systems, standard data types, variables and scope, primitive and referenced data, casting, arrays, input/output, strings, and abstract data types. The published framework therefore connects representation to both arithmetic and program behavior. Study the exact operation named in a question, and keep the language-specific rules separate from a fixed-width model presented for an example.

The test is a selected-response CAT. A candidate may need to interpret a code segment or calculate from a stated representation. Practice by writing out the place values and conversion steps rather than jumping to an answer. When a prompt omits a necessary representation detail, look at the surrounding code or language declaration before concluding that the question has a unique result.

Common questions

How many values can an unsigned eight-bit pattern represent?

It has 256 possible patterns, corresponding to unsigned values 0 through 255 under the usual positional binary interpretation. For a reliable answer, state the relevant assumption and verify it against the official framework or language documentation before applying it to a new example.

Does every decimal fraction repeat in binary?

No. Values such as 0.5 and 0.75 have finite binary forms, while one-tenth repeats in binary. For a reliable answer, state the relevant assumption and verify it against the official framework or language documentation before applying it to a new example.

Does Python integer addition wrap at 255?

No. Python integers have arbitrary precision subject to practical limits. A specified fixed-width eight-bit storage model can behave differently. For a reliable answer, state the relevant assumption and verify it against the official framework or language documentation before applying it to a new example.

Does formatting a float to two decimals make the stored number exact?

No. Formatting controls displayed text; it does not generally change the underlying stored binary floating-point approximation. For a reliable answer, state the relevant assumption and verify it against the official framework or language documentation before applying it to a new example.