Comment

Comment by rep_lodsb

Possibly better solution:

    let m = x.to_bits() & f32::MANTISSA_MASK;
    return f32::from_bits(x.to_bits() ^ (m & (m-1));
Isolate mantissa, clear lowest bit in it, return bit difference as new float. Any problems with this?
parent rep_lodsb 13 days ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton