Skip to content

Printing an i128/u128 shows only its low 64 bits (f"{x}" of 1 << 100 prints 0) #1922

Closed

Description

@ehartford

Found by the #1874 SIMD work (128-bit lanes); reproduced on the installed compiler (main 8f84428's release):

fn main:
    let one: i128 = 1
    let x = one << 100
    print(f"{x >> 90}")   // 1024  (the value is right)
    print(f"{x}")         // 0     (expected 1267650600228229401496703205376)

The value is correct (shift and == give the right answers); the Display/format path for i128/u128 formats the low 64 bits. Spec §4.1 lists i8…i128 and u8…u128 as primitives; a primitive that prints wrong is a silent wrong answer. Expected: full-width decimal (and hex/bin format specs) for 128-bit integers.

Activity

  1. ehartford commented on Sep 30, 2026

    @ehartford
    ContributorAuthor

    Fixed on main: 55d094b (#1929) — i128/u128 print their full value; unsigned and narrow values keep their width under a format spec; i64::MIN under :d no longer panics (LLVM and C backends); behav_1922_integer_format_full_width.

  2. added a commit that references this issue on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions