From: Dave Harris (brangdon_at_[hidden])
Date: 2004-05-06 14:39:51
ramey_at_[hidden] (Robert Ramey) wrote (abridged):
> > > Specifically, I'd use a byte oriented scheme where the low 7 bits of
> > > each byte contribute to the current number, and the high bit says
> > > whether there are more bytes to come.
> That's the way it's done in demo_portable_binary_archive included in the
> current serialization package.
Yes. Demo_portable_binary_archive stores a length byte followed by the
bytes needed. I specifically wanted to suggest an alternative to that.
Using a bit from each byte means that small integers take half as much
space as with your format. Some numbers of bytes:
Integer Length Byte High Bit
0 2 1
10 2 1
100 2 1
1000 3 2
10000 3 2
100000 4 3
In practice most integers are small. Eg most archive version numbers will
be below 100.
-- Dave Harris, Nottingham, UK
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk