While working on https://github.com/apache/daffodil/pull/1391 I was attempting to create a range check test for packed decimal and I noticed that attempting to represent INT_MAX (2,147,483,647) would require at least 5 bytes (6 with sign byte). However, having a schema element with type="xs:int" length="5" will result in an Schema Definition Error saying that the length in bits for an xs:int must be between 1 and 32. So it seems that we are using the same range checks for packed numbers as we are for 2's complement.
According to section 12.3.7.2.3 of the spec: "The maximum specified length of a packed decimal number is implementation-defined." I'm not sure if the maximum specified length is referring to the max length for each numeric type, but assuming it is do we want to use the same checks as we do for 2's complement? I believe the changes I have made in #1391 will create appropriate errors when attempting to convert a number into a smaller type, but I can't currently test this as packed numbers will require more bytes than 2's complement and trigger the SDE. Should these range checks be changed to check the value represented by the packed number instead of the number of bytes it takes up? Or will having an xs:int with length > 4 end up being confusing? Thoughts? Josh