<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Floats on rustbites</title><link>https://www.rustbites.com/tags/floats/</link><description>Recent content in Floats on rustbites</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sat, 25 Apr 2026 16:08:37 +0200</lastBuildDate><atom:link href="https://www.rustbites.com/tags/floats/index.xml" rel="self" type="application/rss+xml"/><item><title>101. f64::total_cmp — Sort Floats Without the NaN Panic</title><link>https://www.rustbites.com/posts/bite-101/</link><pubDate>Fri, 24 Apr 2026 17:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-101/</guid><description>&lt;p&gt;Tried &lt;code&gt;v.sort()&lt;/code&gt; on a &lt;code&gt;Vec&amp;lt;f64&amp;gt;&lt;/code&gt; and hit &lt;code&gt;the trait Ord is not implemented for f64&lt;/code&gt;? Then reached for &lt;code&gt;.sort_by(|a, b| a.partial_cmp(b).unwrap())&lt;/code&gt; and now a stray &lt;code&gt;NaN&lt;/code&gt; is about to panic your service at 3am? &lt;code&gt;f64::total_cmp&lt;/code&gt; is the one-liner that makes both problems disappear.&lt;/p&gt;</description></item></channel></rss>