mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
testsuite: Fix another ubsan warning
The expression here was a bit too dense for ubsan to figure out what branches aren't hit.
This commit is contained in:
parent
deec2b6c6c
commit
5d1b8399fb
@ -73,7 +73,18 @@ float_to_half (const float x)
|
||||
const guint b = *(guint*)&x+0x00001000; // round-to-nearest-even
|
||||
const guint e = (b&0x7F800000)>>23; // exponent
|
||||
const guint m = b&0x007FFFFF; // mantissa
|
||||
return (b&0x80000000)>>16 | (e>112)*((((e-112)<<10)&0x7C00)|m>>13) | ((e<113)&(e>101))*((((0x007FF000+m)>>(125-e))+1)>>1) | (e>143)*0x7FFF; // sign : normalized : denormalized : saturate
|
||||
guint n0 = 0;
|
||||
guint n1 = 0;
|
||||
guint n2 = 0;
|
||||
|
||||
if (e > 112)
|
||||
n0 = (((e - 112) << 10) & 0x7C00) | m >> 13;
|
||||
if (e < 113 && e > 101)
|
||||
n1 = (((0x007FF000 + m) >> (125- e)) + 1) >> 1;
|
||||
if (e > 143)
|
||||
n2 = 0x7FFF;
|
||||
|
||||
return (b & 0x80000000) >> 16 | n0 | n1 | n2; // sign : normalized : denormalized : saturate
|
||||
}
|
||||
|
||||
static gsize
|
||||
|
Loading…
Reference in New Issue
Block a user