firebird
firebird copied to clipboard
Configurable numeric operation (division)
Hi all!
Discussons on this topic: https://github.com/FirebirdSQL/firebird/issues/6928 https://www.mail-archive.com/[email protected]/msg20326.html
Here is my proposal. Things which should be configurable
1. two integer type division result
config name: "integer_division" options:
- DEFAULT: current default, aka BIGINT. integer div
- BIGINT: integer div
- MAXINT: bigger integer from operands types. integer div
- DOUBLE PRECISION: classical division
- DECFLOAT[(16), (34)]: 34, if size not specified. classical division
- DECIMAL[(precision, scale)]: optinal precision and scale from config, (38, 15), if not specified. classical division
- NUMERIC[(precision, scale)]: optinal precision and scale from config, (38, 15), if not specified. classical division
2. division result type, where at least one operand is a real type
config name: "real_division" options:
- DEFAULT: current default, aka NUMERIC(18, op1.scale+op2.scale).
- DOUBLE PRECISION: see integer_div
- DECFLOAT... : see integer_div
- DECIMAL... : see integer_div
- NUMERIC... : see integer_div
3. calculation method
config name: "calc_method" options:
- DEFAULT: current default, digits calculated until result type scale is reached (no operand conversion, "early stop" which leads to trunc effect)
- CLASSICAL: Operands converted to result type when needed and calcualtions happens in that data type. If implicit conversion happens and leads to precision loss (eg: 1E-108 can't be represented in DECIMAL), then exception should be throwed, instead of roundig/truncating.
Thank you!