kasparsklavins / bigint

A lightweight big integer library for c++
MIT License
220 stars 55 forks source link

Incorrect product sign for negative values #26

Open louiev opened 6 years ago

louiev commented 6 years ago
typedef long double ldbl;

const int imax = numeric_limits< int >::min();
ldbl xdbl = pow(static_cast< ldbl >(imax), 5);
Dodecahedron::Bigint ibig = imax;
Dodecahedron::Bigint xbig = ibig.pow(5);

imax = -2147483648 xdbl = -4.56719e+046 xbig = 45671926166590716193865151022383844364247891968

The sign is incorrect for xbig.

The same incorrect result is obtained with Dodecahedron::Bigint xbig = ibig ibig ibig ibig ibig;