Skip to content

Commit 40ba8e0

Browse files
committed
Parse floats up to 64b
1 parent 9df86b8 commit 40ba8e0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/libAtomVM/opcodesswitch.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,14 @@ typedef dreg_t dreg_gc_safe_t;
224224
case COMPACT_NBITS_VALUE:{ \
225225
int sz = (first_byte >> 5) + 2; \
226226
if (UNLIKELY(sz > 8)) { \
227-
/* TODO: when first_byte >> 5 is 7, a different encoding is used */ \
228-
fprintf(stderr, "Unexpected nbits vaue @ %" PRIuPTR "\n", (uintptr_t) ((decode_pc) - 1)); \
229-
AVM_ABORT(); \
230-
break; \
227+
sz = *(decode_pc) + 9; \
228+
(decode_pc)++; \
229+
/* Integer larger than 60-bits but no bigger than 64-bits */ \
230+
/* will become boxed term taking 9 bytes (1 byte box + 64 bits)*/ \
231+
/* AtomVM can handle 64 bit int, but not larger ones until BigNum support is ready*/ \
232+
if (sz > 9 && (first_byte & 0xF) == COMPACT_LARGE_INTEGER) { \
233+
fprintf(stderr, "WARNING: Loading integer possibly longer than 64 bits"); \
234+
} \
231235
} \
232236
(decode_pc) += sz; \
233237
break; \

0 commit comments

Comments
 (0)