Open and answer this issue on GitHub.
ready · opened 2026-10-19 · updated 2026-10-20 · 1 comment
The 1BRC study’s fast.nika (phase 3, gaps/05-u8-wrapping.nika): b[j] - '0' on a u8 is a checked subtraction, and u8 has no wrapping_sub, so the program wrote (b[j] as i32) - 48 (−8.3 instructions/row). Checked on 0.0.1097: c.wrapping_sub(48) with c: u8 is refused (“A number’s methods are the ones std describes, and none of them is called wrapping_sub”). Part I listed the wrapping/saturating/checked names “for i32, i64, u32 and u64”, and the conversions had no u8 destination; no record gave a reason, and ADR-285 D7 says “saturating_ wherever Rust has it”.
ADR-285 D41: u8 has every name the other fixed widths have — wrapping_, saturating_, checked_ arithmetic as for u32 (no _neg/_abs), and truncating_u8 / checked_u8 out of a wider integer and an f64. Part I 2.2 updated; ADR-315 D1, D4 updated.
std.contracts (+ the checker’s number-method table, wherever wrapping_sub on u32 is described): the u8 entries for wrapping_add/sub/mul/div/shl/shr, saturating_add/sub/mul/div, checked_add/sub/mul/div/rem; truncating_u8 and checked_u8 on i32, i64, u32, u64, f64. Lowered to Rust’s names / as / u8::try_from as for the other widths.let c: u8 = 55; c.wrapping_sub(48) == 7; (3 as u8).wrapping_sub(5) == 254; (250 as u8).saturating_add(10) == 255; (250 as u8).checked_add(10) == null; 300.truncating_u8() == 44; 300.checked_u8() == null, 200.checked_u8() == 200; (-1.5).truncating_u8() == 0; u8 has no wrapping_neg (refused).fast.nika in the 1BRC study can then write b[j].wrapping_sub(b'0').Steps 1 to 3 are built in f24f5c1 (version 0.0.1131), with two exceptions:
f64::checked_u8 is missing. No f64::checked_* conversion exists for any width, so this is now #749.200.checked_u8() == 200 is temporarily written as (… ?? 0) == 200 because of the lowering defect #748.Step 4 (fast.nika in the 1BRC study) is still open.
Generated by Claude Code