JanetDocsPlaygroundI'm feeling luckyGitHub sign in

buffer/push-word



    cfunction

    (buffer/push-word buffer & xs)

    Append machine words to a buffer. The 4 bytes of the integer are 
    appended in twos complement, little endian order, unsigned for all 
    x. Returns the modified buffer. Will throw an error if the buffer 
    overflows.


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