p32_mul( 32, lastbefore(lastbefore(-maxpos)) ) rounds differently from double multiply
My fuzzer found this:
function posit32_mul: slow and [softposit] disagree
slow : 80000001
: 80000002
arg0: 64000000
arg1: 80000003
and I'm not entirely sure who is right, but I found that converting to double, doing the multiplication, then converting back rounds differently so I think I can report this one here.
#include "../..//source/include/softposit.h"
#include <assert.h>
int main () {
posit32_t a, b, c;
a.v = 0x64000000u;
b.v = 0x80000003u;
c = p32_mul(a, b);
double da = convertP32ToDouble(a);
double db = convertP32ToDouble(b);
double dc = da * db;
posit32_t c2 = convertDoubleToP32(dc);
printf("c = %08x da=%.20f db=%.20f dc=%.20f c2=%08x\n", c.v, da, db, dc, c2.v);
}
notgay:Linux-x86_64-GCC user$ ./a.out
c = 80000002 da=32.00000000000000000000 db=-20769187434139310514121985316880384.00000000000000000000 dc=-664613997892457936451903530140172288.00000000000000000000 c2=80000001