Skip to content

Commit

Permalink
Fixup bounds for negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Jan 15, 2024
1 parent 049c58c commit 22e550e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/obj_long.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ static int formatLongCallback(void * a, int base, int *more) {
static char * krk_long_to_decimal_str(const KrkLong * value, size_t * len);
static fmtCallback prepLongCallback(void * a, int base) {
struct _private * val = a;
if (base != 10 || (val->val->width >= 10 && val->val->width < 10)) {
if (base != 10 || (val->val->width > -10 && val->val->width < 10)) {
uint32_t hash = 0;
val->asStr = krk_long_to_str(val->val, base, "", &val->len, &hash);
} else {
Expand Down Expand Up @@ -2303,7 +2303,7 @@ KRK_Method(long,__repr__) {
/* For rather small values (10 was chosen arbitrarily), use the older approach */
size_t len;

if (self->value->width >= -10 && self->value->width < 10) {
if (self->value->width > -10 && self->value->width < 10) {
uint32_t hash;
char * rev = krk_long_to_str(self->value, 10, "", &len, &hash);
return OBJECT_VAL(krk_takeStringVetted(rev,len,len,KRK_OBJ_FLAGS_STRING_ASCII,hash));
Expand Down

0 comments on commit 22e550e

Please sign in to comment.