Reorganize TOP_BIT constants

This commit is contained in:
Lassi Kortela 2019-10-14 01:22:56 +03:00
parent f80305fd73
commit d8bd8c2beb
2 changed files with 8 additions and 7 deletions

View File

@ -1195,8 +1195,8 @@ static value_t fl_neg(value_t n)
return fixnum(-(int32_t) * (uint16_t *)a);
case T_INT32:
i32 = *(int32_t *)a;
if (i32 == (int32_t)BIT31)
return mk_uint32((uint32_t)BIT31);
if (i32 == (int32_t)INT32_TOP_BIT)
return mk_uint32((uint32_t)INT32_TOP_BIT);
return mk_int32(-i32);
case T_UINT32:
ui32 = *(uint32_t *)a;
@ -1205,8 +1205,8 @@ static value_t fl_neg(value_t n)
return mk_int64(-(int64_t)ui32);
case T_INT64:
i64 = *(int64_t *)a;
if (i64 == (int64_t)BIT63)
return mk_uint64((uint64_t)BIT63);
if (i64 == (int64_t)INT64_TOP_BIT)
return mk_uint64((uint64_t)INT64_TOP_BIT);
return mk_int64(-i64);
case T_UINT64:
return mk_int64(-(int64_t) * (uint64_t *)a);

View File

@ -10,10 +10,11 @@ typedef intptr_t fixnum_t;
#define U64_MAX 18446744073709551615ULL
#define S64_MAX 9223372036854775807LL
#define S64_MIN (-S64_MAX - 1LL)
#define BIT63 0x8000000000000000LL
#define BIT31 0x80000000
#define INT32_TOP_BIT 0x80000000
#define UINT32_TOP_BIT 0x80000000
#define INT64_TOP_BIT 0x8000000000000000LL
#define UINT64_TOP_BIT 0x8000000000000000ULL
#if UINTPTR_MAX == 0xffffffffffffffffULL
@ -29,7 +30,7 @@ typedef intptr_t fixnum_t;
#endif
#define LOG2_10 3.3219280948873626
#define sign_bit(r) ((*(int64_t *)&(r)) & BIT63)
#define sign_bit(r) ((*(int64_t *)&(r)) & INT64_TOP_BIT)
#define NBABS(n, nb) (((n) ^ ((n) >> ((nb)-1))) - ((n) >> ((nb)-1)))
#define DFINITE(d) \
(((*(int64_t *)&(d)) & 0x7ff0000000000000LL) != 0x7ff0000000000000LL)