Skip to content

[clang-format] Feature Request: FloatingPointLiteralSeparator #131510

@xhrnca00

Description

@xhrnca00

Clang-format already has an IntegerLiteralSeparator option that adds separators to integer literals. When I started using it, it confused me there was no alternative for floating point literals.

It would be great to either:

  1. Add a new option called FloatingPointLiteralSeparator, which would do the same as its integer alternative, only for floating point literals.
  2. Expand the existing IntegerLiteralSeparator to apply the formatting to floating point literals.

I was imagining something like:

# .clang-format
FloatingPointLiteralSeparator:
  Decimal: 3
  DecimalMinDigits: 5
  Hex: 4
  HexMinDigits: 5

The resulting format could look like this:

// Before
double decimal = 12345678.12345678e-50;
double hexa = 0x1234567.89abcdfp-100;

// After
double decimal = 12'345'678.123'456'78e-50;
double hexa = 0x123'4567.89ab'cdfp-100;

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions