Long numeric literal without regular digit-separator grouping

ID

c.maintainability.digit_separator_grouping

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Numeric Literal

Language

C / C++

Description

Reports a decimal integer literal of five or more digits written without ' digit separators, or one whose ' separators are not grouped in regular runs of three digits.

Rationale

A run of five or more undifferentiated digits (100000000) has to be counted character by character to read its magnitude, and a single mistyped or dropped digit changes the value silently with no visual cue. C++14’s ' digit separator exists to make magnitude readable at a glance, but only when applied in regular groups - an irregular grouping like 1'00'000 is just as easy to misread as no grouping at all.

The following code illustrates the pattern detected by this rule:

void f1(void) {
  // FLAGGED: Long numeric literal without regular digit-separator grouping
  int a = 1000000;
}

Remediation

Group the literal’s digits with ' in regular runs of three from the right, e.g. 100'000'000 instead of 100000000 or 1'00'000.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved