amazon-ion / ion-schema

The Ion Schema Specification. This specification is licensed under the Apache 2.0 License.
https://amazon-ion.github.io/ion-schema/
Apache License 2.0
13 stars 10 forks source link

SQL Decimal Cookbook erroneously refers to "adjusted exponent" #109

Open popematt opened 1 year ago

popematt commented 1 year ago

SQL Decimal Cookbook

Because an Ion decimal can have more than one encoding, the value of the exponent property is actually the adjusted exponent as defined in the IBM Hursley Lab General Decimal Arithmetic Specification:

The adjusted exponent is the value of the exponent of a number when that number is expressed as though in scientific notation with one digit (non-zero unless the coefficient is 0) before any decimal point. This is given by the value of the exponent+(clength–1), where clength is the length of the coefficient in decimal digits.

For example, the adjusted exponent of the values 0.00123d2 and 0.123d0 is the exponent of the adjusted form, 1.23d-1.

All of the modeling guidance that the cookbook provides is correct, but the Ion data model doesn't actually use the adjusted exponent. It just uses the regular exponent as defined in the Decimal data model. See also exponent in the ISL 2.0 spec.