Basic Structures
[Strings] [String]
Strings
A string is encoded as a «SListB».. Strings use «ASCII Codes»..
[Offsets] [Offset]
Offsets
At many places, other locations in the file are referenced. These locations are given as Offsets: the number of bytes from the start of the file. Offsets are always encoded in Longs.
[Lengths] [Length]
Lengths
Lengths are encoded within longs. The unit is a twip, or 1/5A0 inch (1/1440 decimal). This means 237 (567 decimal) units correspond to 1 cm.
[Sizes][Size]
Sizes
Font sizes are expressed within longs. The unit is a 1/14 point (1/20 decimal). As a point equals 1/48 twip (1/72 decimal), this is actually the same unit as used for «Lengths».
[Colors][Color]
Colors
Colors are encoded within three bytes. Each byte ranges from 00 (black) to FF (white). This is clearly intended to be a RGB encoding, but the Psion 5 only has a greytone display. All three bytes should be equal to express a greytone, and in practice, only values 00 00 00, 55 55 55, AA AA AA and FF FF FF are seen.
Signed Integers
[SInt][SInts][Signed Integer][Signed Integers]
Signed integers are encoded in longs. The most significant bit is used as sign (0 for positive, 1 for negative). So +1 is encoded as 01 00 00 00, and -1 as 01 00 00 80.
Floating Point Numbers
[Float][Floats][Floating Point Numbers]
Floating point numbers are encoded in 8 bytes. The most significant bit is used as sign (0 for positive, 1 for negative). The next B (11 decimal) bits are used as a two-complement exponent, and the remaining 34 (52 decimal) bits are used as the mantissa.
The complete number can be found through this C formula (>> means shift right, ** means to the power of, Float is the 8 byte unsigned integer representation):
(Float & 0x8000000000000000 ? -1 : 1) *
(1 + (Float & 0x000FFFFFFFFFFFFF) / 0x0010000000000000) *
(2 ** (((Float & 0x7FF0000000000000) >> 52) - 0x3FF)
Some example representations:
Number (decimal) Sign bit Exponent Mantissa Complete
1.0 0 3FF 0000000000000 00 00 00 00 00 00 F0 3F
2.0 0 400 0000000000000 00 00 00 00 00 00 00 40
3.0 0 400 8000000000000 00 00 00 00 00 00 08 40
3.5 0 400 C000000000000 00 00 00 00 00 00 0C 40
-3.5 1 400 C000000000000 00 00 00 00 00 00 0C C0
0.5 0 3FE 0000000000000 00 00 00 00 00 00 E0 3F
0.0 0 000 0000000000000 00 00 00 00 00 00 00 00