Hi hackers, While working with PG, I found that to_char returns value that is right but the format is wrong: SELECT to_char(999::numeric, '9.9EEEE'); Result is: 10.0e+02, and I think the expected output should be: 1.0e+03. With help from ChatGPT, I figured that get_str_from_var_sci() determines the exponent before rounding the significand. If rounding increases the significand's absolute value to 10, the original exponent is still used. The attached patch adds a check for this,and adjusts the significand and the exponent.
Regards, hanjianqiao
v1-0001-Normalize-numeric-bigint-scientific-notation-a.patch
Description: Binary data
