libcg / bfp

Beyond Floating Point - Posit C/C++ implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Max posit width

Tongdongq opened this issue · comments

What is the maximum posit width? I tested successfully with 32 bits (es=2), but for 33 bits, it doesn't work. I see POSIT_WIDTH = 32 in posit_types.h. And Posit::mBits is of type POSIT_UTYPE, which is uint32_t.
I tried small changes in posit_types.h, but that doesn't fix it. Do you know if I can change to 32+ bits easily?

You can try this:

#define POSIT_LUTYPE    uint128_t
#define POSIT_UTYPE     uint64_t
#define POSIT_STYPE     int64_t
#define POSIT_WIDTH     64
#define POSIT_ZERO      ((POSIT_UTYPE)0x0000000000000000LL)
#define POSIT_ONE       ((POSIT_UTYPE)0x4000000000000000LL)
#define POSIT_MONE      ((POSIT_UTYPE)0xC000000000000000LL)
#define POSIT_INF       ((POSIT_UTYPE)0x8000000000000000LL)
#define POSIT_MSB       ((POSIT_UTYPE)0x8000000000000000LL)
#define POSIT_MASK ((POSIT_UTYPE)0xFFFFFFFFFFFFFFFF)

I looked a bit more into it and there's a bunch of places where the code assumes 32-bit. Recent updates will cause compilation to fail if you try to use POSIT_WIDTH > 32. It will certainly be worth revisiting later.