Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Like the other languages discussed in this chapter, Turbo Pascal supports
  integer, floating-point, and string data types. Integers are stored in the
  familiar 2-byte format, but floating-point and string representations
  present some novelties.

  Turbo Pascal version 4.0 supports five types of floating-point (real)
  numbers. The REAL type is a 6-byte, floating-point representation designed
  by Borland. The other four (SINGLE, DOUBLE, EXTENDED, and COMP) are
  representations used by the 8087 math coprocessor.

  Turbo Pascal stores strings in a simple data structure: a 1-byte count
  that is followed by the string data itself. (See Figure 20-2.) The count
  byte is treated as an unsigned value, so the maximum length of a string is
  255 (FFH) bytes.

  String length---+           String data
                 +.-------------------------------------+
                 |11|H |e |l |l |o |, |  |W |o |r |l |d |
                 +--------------------------------------+

  Figure 20-2.  String data representation in Turbo Pascal.

  Turbo represents other Pascal data types in equally reasonable ways. For
  example, Boolean values are represented in a single byte (01H = true, 00H
  = false). Sets are represented as bit strings in which the position of
  each bit corresponds to the ordinal value of one member of the set. (See
  Figure 20-3.) The low-order bit in each byte corresponds to an ordinal
  value that is evenly divisible by 8. The compiler stores only as many
  bytes as are needed to represent the set.

   TYPE LETTERS = 'a' .. 'z'; {ordinal values 97 through 122}
   VAR X :SET OF LETTERS;

   X := ['a', 'b', 'c', 'y', 'z'];
  +---------------++---------------++---------------++---------------+
  |0|0|0|0|1|1|1|0||0|0|0|0|0|0|0|0||0|0|0|0|0|0|0|0||0|0|0|0|0|1|1|0|
  +---------------++---------------++---------------++---------------+
           c b a                                                z y

  Figure 20-3.  Representation of a set in Turbo Pascal. The set X is
  represented as a 4-byte bit string in which each bit corresponds to one of
  the ordinal values `a' through `z' (decimal 97 through 122). The bits are
  aligned so that ordinal values evenly divisible by 8 are represented in
  bit 0 of each byte.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson