Signed divide of 32bit values

Signed divide of 32bit values can overflow if done in a 32bit long
due to the truncation of sign bits. So use the large value algorithm
if the values are >= 31 bits (63 bits on 64bit machines).

Signed-off-by: Stephen Williams <steve@icarus.com>
This commit is contained in:
Stephen Williams 2007-09-01 14:38:57 -07:00
parent 4f6b47b345
commit 4af28c7526
1 changed files with 1 additions and 1 deletions

View File

@ -947,7 +947,7 @@ verinum operator / (const verinum&left, const verinum&right)
result is signed or not. */ result is signed or not. */
if (result.has_sign()) { if (result.has_sign()) {
if (use_len <= 8*sizeof(long)) { if (use_len <= (8*sizeof(long) - 1)) {
long l = left.as_long(); long l = left.as_long();
long r = right.as_long(); long r = right.as_long();
long v = l / r; long v = l / r;