Comparisons between negative posit32 values and non-negative posit32 values are incorrect
I originally though this issue was isolated to some very small negative numbers, but it seems to apply to any comparison between numbers with different signs. For example:
// File demo.c
#include "softposit.h"
int main (int argc, char *argv[]){
posit32_t a, b;
a = castP32(0xb4000000);
b = castP32(0x48000000);
printf("a.v is 0x%08x, a = %1.17e\n", a.v, convertP32ToDouble(a));
printf("b.v is 0x%08x, b = %1.17e\n", b.v, convertP32ToDouble(b));
printf("a < b is %d\n", p32_lt(a, b));
printf("a <= b is %d\n", p32_le(a, b));
printf("b < a is %d\n", p32_lt(b, a));
printf("b <= a is %d\n", p32_le(b, a));
return 0;
}
Run on my machine (Ubuntu 16.04, compiled with "make python3") this prints the following:
$ gcc -o demo demo.c SoftPosit/build/Linux-x86_64-GCC/softposit.a -ISoftPosit/source/include -O0 -lm
$ ./demo
a.v is 0xb4000000, a = -3.00000000000000000e+00
b.v is 0x48000000, b = 2.00000000000000000e+00
a < b is 0
a <= b is 0
b < a is 1
b <= a is 1
Comparisons between numbers with the same sign (i.e. p32_lt(-4, -3)) seem to be working fine, as are comparisons for posit16 and posit8.