A three-dimensional data encoding device which encodes three-dimensional data, the three-dimensional data encoding device comprising:
- a processor;
- and
- memory,
- wherein, using the memory, the processor:
- calculates a predicted value of a current value to be encoded included in the three-dimensional data;
- calculates a prediction residual which is a difference between the current value and the predicted value;
- binarizes the prediction residual to generate binary data including a prefix and a suffix;
- selects a first context to be used to arithmetic encode a current bit of the suffix;
- selects a second context to be used to arithmetic encode a current bit of the prefix;
- and
- arithmetic encodes the binary data, and
- in the arithmetic encoding of the binary data, (i) the first context is applied to the current bit of the suffix, and (ii) the second context is applied to the current bit of the prefix.