JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

buffer/push-word

core-api


    cfunction
    src/core/buffer.c on line 286, column 1

    (buffer/push-word buf & xs)

    Append machine words to a buffer, `buf`. The 4 bytes of the integer 
    are appended in two's complement, little endian order, unsigned for 
    all x. Returns `buf`. Expands `buf` as needed. Throws an error if 
    size limit is exceeded.


1 exampleSign in to add an example
Loading...
(var buf @"")
(buffer/push-word buf 2147483647)

(+
  (get buf 0)                # byte 1
  (blshift (get buf 1) 8)    # byte 2
  (blshift (get buf 2) 16)   # byte 3
  (blshift (get buf 3) 24))  # byte 4

# => 2147483647
leobmPlayground