softposit 0.4.0

Implementation of Posit numbers
Documentation
use super::P8E0;

const LOG8: [u8; 128] = [
    128, 144, 148, 152, 154, 156, 157, 158, 159, 161, 165, 168, 170, 173, 175, 178, 180, 182, 183,
    185, 187, 188, 190, 191, 193, 196, 198, 201, 203, 205, 208, 210, 212, 214, 216, 217, 219, 221,
    223, 224, 226, 228, 229, 231, 232, 233, 235, 236, 238, 239, 240, 241, 243, 244, 245, 246, 247,
    249, 250, 251, 252, 253, 254, 255, 0, 2, 4, 6, 8, 9, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25,
    26, 27, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 48, 52, 55, 59, 62, 64, 66,
    67, 68, 70, 71, 72, 73, 74, 75, 76, 80, 84, 87, 89, 92, 94, 96, 97, 98, 100, 101, 102, 105,
    108, 112,
];

impl P8E0 {
    pub const fn ln(self) -> Self {
        let u_a = self.to_bits();
        if u_a > 127 {
            Self::NAR
        } else {
            Self::from_bits(LOG8[u_a as usize])
        }
    }
}