## What is TeX’s memoryword structure in C?

Just a brief post, partly to record this for my own use. If you read the source code of TeX you will see references to a data structure called a *memoryword*. It is very carefully defined in the source file `texmfmem.h`

, using various `#ifdef`

blocks to account for endian-type and the "flavour" of TeX you are compiling. So, here is the `memoryword`

, stripped to the very basics for my *Windows-only* build of TeX. On my machine, `sizeof(memoryword)`

= 8 bytes – `glueratio`

is defined as the type `double`

(8 bytes) – TeX does use the type `double`

for glue calculations. From section 109 of the TeX source code:

When TEX "packages" a list into a box, it needs to calculate the proportionality ratio by which the glue inside the box should stretch or shrink. This calculation does not affect TEX's decision making, so the precise details of rounding, etc., in the glue calculation are not of critical importance for the consistency of results on different computers.

#define glueratio double typedef unsigned char quarterword ; typedef int integer; typedef integer halfword ; typedef union { struct { int LH, RH; } v; struct { short B1, B0; } u; } twohalves; typedef struct { struct { quarterword B3, B2, B1, B0; } u; } fourquarters; typedef union { glueratio gr; twohalves hh; struct { halfword junk; integer CINT; } u; struct { halfword junk; fourquarters QQQQ; } v; } memoryword; typedef union { struct { integer CINT; } u; struct { fourquarters QQQQ; } v; } fmemoryword;