With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Storing numeric values

Attributes that store number values, which need to be sorted or compared, need to use the technique of zero padding so that they work correctly when using lexicographical comparison. If you store two number values `2` and `10`, a normal lexicographical comparison will result in the value `2` being greater than `10`. This is, of course, not exactly what you would expect to get when comparing these values as numbers.

Note

The solution is to store the number values with padding for the right number of digits.

We will store `2` as `02`. Now a lexicographical comparison between `02` and `10` will return what you expect! In order to pad your data correctly, you need to know the limits of the number values that will be stored. If you know how large ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required