From 3a2f2d326bfe882ff518f194f041e1c55cb93fc8 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Tue, 18 Apr 2023 18:45:56 +0200 Subject: [PATCH] better float trickery --- thiersort.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/thiersort.h b/thiersort.h index f2d3cac..f031aae 100644 --- a/thiersort.h +++ b/thiersort.h @@ -411,14 +411,16 @@ static inline TSU8 ts_radixi( k.f = (float)(arr[i].u); /* 8 bit float */ - k.u >> 24; + /* top bit always zero so ignore it and use 8 useful bits */ + /* - this is why we shift 23 and not 24 here */ + k.u >> 23; /* We are fine! */ return (TSU8)k.u; } if(isfloat) { /* Sign bit can be 1! */ - k.f = (float) (arr[i].f); + k.f = arr[i].f; /* 8 bit float */ k.u >> 24;