shithub: femtolisp

Download patch

ref: 54110775fb881f4690940b07d57b8555bb325f75
parent: 9bfee88015312110df5100c28e5db198e79dbd2b
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Nov 30 07:49:39 EST 2020

fix lognot for 8 and 16-bit numbers

--- a/cvalues.c
+++ b/cvalues.c
@@ -1479,9 +1479,9 @@
         aptr = cp_data(cp);
         switch (ta) {
         case T_INT8:   return fixnum(~*(int8_t *)aptr);
-        case T_UINT8:  return fixnum(~*(uint8_t *)aptr);
+        case T_UINT8:  return fixnum(~*(uint8_t *)aptr & 0xff);
         case T_INT16:  return fixnum(~*(int16_t *)aptr);
-        case T_UINT16: return fixnum(~*(uint16_t*)aptr);
+        case T_UINT16: return fixnum(~*(uint16_t*)aptr & 0xffff);
         case T_INT32:  return mk_int32(~*(int32_t *)aptr);
         case T_UINT32: return mk_uint32(~*(uint32_t*)aptr);
         case T_INT64:  return mk_int64(~*(int64_t *)aptr);