From fe849ca438b8110bab519a119e512568b03ff907 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Tue, 22 Sep 2026 00:48:10 +0800 Subject: floatPower2 --- bits.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bits.c b/bits.c index 0e2935d..c299fe0 100644 --- a/bits.c +++ b/bits.c @@ -311,5 +311,14 @@ int float64_f2i(unsigned uf1, unsigned uf2) { * Difficulty: 4 */ unsigned floatPower2(int x) { - return 2; + if (x < -149) { + return 0; + } + if (x < -126) { + return 1 << (x + 149); + } + if (x <= 127) { + return (x + 127) << 23; + } + return 0x7F800000; } -- cgit v1.2.3