RS.CLIPPY.DECIMAL_LITERAL_REPRESENTATION

Using decimal representation when hexadecimal would be better

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: decimal_literal_representation. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Warns if there is a better representation for a numeric literal.

Why restrict this?

Especially for big powers of 2, a hexadecimal representation is usually more readable than a decimal representation.

Example

`255` => `0xFF`
`65_535` => `0xFFFF`
`4_042_322_160` => `0xF0F0_F0F0`

Configuration

  • literal-representation-threshold: The lower bound for linting decimal literals

    (default: 16384)