Question

# 问题

Questions in category: 数据结构 (Data Structure).

## clox 中的一些值的设定

Posted by haifeng on 2023-06-03 08:03:31 last update 2023-06-03 11:18:02 | Answers (0) | 收藏

>> hex2decimal(0x7ffc000000000000)
out> 9222246136947933184

>> decimal2binary(9222246136947933184)
out> 111111111111100000000000000000000000000000000000000000000000000

------------------------

0111,1111,1111,1100;00000000,00000000;00000000,00000000;00000000,00000000

#define SIGN_BIT ((uint64_t)0x8000000000000000)

#define QNAN     ((uint64_t)0x7ffc000000000000)

#define IS_NUMBER(value)    (((value) & QNAN) != QNAN)

//     QNAN=0x7ffc000000000000
//TAG_FALSE=0x0000000000000010
// TAG_TRUE=0x0000000000000011
//FALSE_VAL=0x7ffc000000000010
// TRUE_VAL=0x7ffc000000000011

(SIGN_BIT | QNAN)

1111,1111,1111,1100;00000000,00000000;00000000,00000000;00000000,00000000

0000,0000,0000,0011;11111111,11111111,11111111,11111111,11111111,11111111

#define AS_OBJ(value) \
((Obj*)(uintptr_t)((value) & ~(SIGN_BIT | QNAN)))

AS_OBJ() 函数就是将 value 和上面的值  0x3ffffffffffff 作与运算