Interpret scalar values using their declared types
02Signedness, legal enum values and floating-point layout come from the data description. A boolean is a four-byte enum, not one byte.
Actual width is 64:128 with field partitions1/11/52 and 1/15/112. Special values and arithmetic support are separate from these layouts.
Source for this drawing: RFC 4506 · Read RFC section 4.1 ↗
New to this? Start hereA quick picture + helpful background
First, agree how to read the message.
An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
The same bits can have different meanings; scalar type constraints still apply.
- A signed int is 32-bit two’s complement in−2147483648…2147483647. An unsigned int is 32 bits in 0…4294967295. Bytes ff ff ff fe therefore mean −2 under int and 4294967294 under unsigned int; the schema chooses the interpretation (§§4.1–4.2).
- An enum has the signed-int representation, but encoding an unassigned value is an error. Boolean is the enum FALSE=0,TRUE=1, still four bytes; arbitrary nonzero integers are not true. In the RFC’s illustrative color enum, only 2,3,5 are assigned, so4 is not legal (§§4.3–4.4). These are separate type examples, not one combined type.
- Hyper and unsigned hyper are64-bit, eight-byte integers, most significant byte first. Signed hyper extends two’s complement; unsigned hyper covers0…2^64−1. The example4294967296 uses00 00 00 01 00 00 00 00. The teaching helper uses BigInt to avoid rounding large integers through JavaScript Number (§4.5).
- Float is 32 bits: sign1 bit, exponent8 bits biased by 127, fraction23 bits. The normalized formula is(−1)^S ×2^(E−bias) ×1.F. The worked value 3.5 has S=0,E=128,F=0x600000 and bytes40 60 00 00 (§4.6). Do not apply that normalized formula blindly to zero, infinity, subnormal or NaN encodings.
- Double is 64 bits with fields1/11/52 and bias1023. Quadruple is 128 bits with fields1/15/112 and bias16383. The final state compares actual bit spans, not host arithmetic support. Sections4.6–4.8 and 11 address special values; a NaN is interpreted only as NaN, not a portable payload or application value. The helper does not implement quadruple arithmetic.
Illustrative values and bounded offline encoding/decoding models. Not a complete XDR compiler, RPC/NFS implementation, transport, memory allocator or security verifier.
Read the RFC section ↗