Home

sfixed64

sfixed64 is a 64-bit fixed-width signed integer field type used in Protocol Buffers. It occupies exactly eight bytes on the wire and uses the fixed64 wire encoding, which is the same eight-byte representation as fixed64 but interpreted as a signed value. The difference from other integer types is in interpretation rather than encoding: sfixed64 represents a signed two’s-complement number, with a range from -2^63 to 2^63-1, whereas fixed64 represents an unsigned 64-bit value from 0 to 2^64-1.

In the binary encoding, sfixed64 is stored as eight raw bytes in little-endian order. There is no

sfixed64 is chosen when a fixed-width signed representation is desirable for performance, alignment, or interoperability reasons.

In most languages, sfixed64 maps to a 64-bit signed integer type, and protobuf tooling generates accessors that

varint
or
zigzag
encoding
for
this
type.
For
example,
the
value
-1
is
encoded
as
eight
0xFF
bytes;
the
value
1
is
encoded
as
01
00
00
00
00
00
00
00.
The
width
is
fixed,
so
the
field
always
consumes
eight
bytes
regardless
of
the
magnitude
of
the
number.
It
is
useful
for
fields
that
are
frequently
accessed,
indexed,
or
compared,
and
when
a
signed
64-bit
interpretation
is
required.
It
is
typically
used
alongside
other
fixed-width
types
like
fixed64
and
sfixed32,
as
well
as
variable-length
types
such
as
int64
and
sint64,
depending
on
the
desired
encoding
characteristics.
read
and
write
values
using
that
type,
preserving
two’s-complement
semantics.