Skip to content

Format fixed-point zero without extra digits - #172

Open
ViktorBystrov72 wants to merge 1 commit into
cockroachdb:masterfrom
ViktorBystrov72:fix/fixed-format-zero
Open

ViktorBystrov72 wants to merge 1 commit into
cockroachdb:masterfrom
ViktorBystrov72:fix/fixed-format-zero

Conversation

@ViktorBystrov72

Copy link
Copy Markdown

Text('f') and %f render 0E+2 as 000, which can occur after multiplying zero by a decimal with a positive exponent. Write 0 for this case and -0 for negative zero, matching Python's decimal fixed-point format.

Fractional zero still retains its scale, and nonzero coefficients still get their exponent padding. The existing format tests cover these cases and the scientific formats.

Fixes #136.

The full race suite passed on Go 1.24.0 and 1.27.3. The repository's go vet -unsafeptr=false ./... check passed as well.

Skip exponent padding for a zero coefficient in fixed-point format.
Keep the sign of negative zero and retain the scale of fractional zero.

Signed-off-by: Виктор Быстров <anatema@bk.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text('f'): 0 x 100 = 000

1 participant