<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Integers on rustbites</title><link>https://www.rustbites.com/tags/integers/</link><description>Recent content in Integers on rustbites</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 17 Apr 2026 12:51:37 +0200</lastBuildDate><atom:link href="https://www.rustbites.com/tags/integers/index.xml" rel="self" type="application/rss+xml"/><item><title>85. cast_signed &amp; cast_unsigned — Explicit Sign Casting for Integers</title><link>https://www.rustbites.com/posts/bite-085/</link><pubDate>Thu, 16 Apr 2026 17:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-085/</guid><description>&lt;p&gt;Stop using &lt;code&gt;as&lt;/code&gt; to flip between signed and unsigned integers — &lt;code&gt;cast_signed()&lt;/code&gt; and &lt;code&gt;cast_unsigned()&lt;/code&gt; say exactly what you mean.&lt;/p&gt;</description></item><item><title>82. isqrt — Integer Square Root Without Floating Point</title><link>https://www.rustbites.com/posts/bite-082/</link><pubDate>Wed, 15 Apr 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-082/</guid><description>&lt;p&gt;&lt;code&gt;(n as f64).sqrt() as u64&lt;/code&gt; is the classic hack — and it silently gives the wrong answer for large values. Rust 1.84 stabilized &lt;code&gt;isqrt&lt;/code&gt; on every integer type: exact, float-free, no precision traps.&lt;/p&gt;</description></item><item><title>81. checked_sub_signed — Subtract a Signed Delta From an Unsigned Without Casts</title><link>https://www.rustbites.com/posts/bite-081/</link><pubDate>Tue, 14 Apr 2026 17:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-081/</guid><description>&lt;p&gt;&lt;code&gt;checked_add_signed&lt;/code&gt; has been around for years. Its missing sibling finally landed: as of Rust 1.91, &lt;code&gt;u64::checked_sub_signed&lt;/code&gt; (and the whole &lt;code&gt;{checked, overflowing, saturating, wrapping}_sub_signed&lt;/code&gt; family) lets you subtract an &lt;code&gt;i64&lt;/code&gt; from a &lt;code&gt;u64&lt;/code&gt; without casting, unsafe, or hand-rolled overflow checks.&lt;/p&gt;</description></item><item><title>78. div_ceil — Divide and Round Up Without the Overflow Bug</title><link>https://www.rustbites.com/posts/bite-078/</link><pubDate>Mon, 13 Apr 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-078/</guid><description>&lt;p&gt;Need to split items into fixed-size pages or chunks? The classic &lt;code&gt;(n + size - 1) / size&lt;/code&gt; trick silently overflows. &lt;code&gt;div_ceil&lt;/code&gt; does it correctly.&lt;/p&gt;</description></item></channel></rss>