Variable-length quantity: Difference between revisions

→‎{{header|TXR}}: Another example.
(→‎{{header|TXR}}: Replace with carray based answer, which directly meets requirements.)
(→‎{{header|TXR}}: Another example.)
Line 1,800:
6> (num-carray *3)
2097151</pre>
 
Conversion to a <code>carray</code> not based on the default <code>uchar</code>:
 
<pre>1&gt; (carray-num #x123456789 (ffi uint32))
#&lt;carray 2 #&lt;ffi-type uint32&gt;&gt;
2&gt; (carray-get *1)
#(16777216 2305246499)</pre>
 
This number requires two 32-bit units to store. Because <code>uint32</code> is in the native endian, opposite to the big endian storage of the integer, the words come out byte swapped. The <code>be-uint32</code> type could be used to change this.
 
=={{header|zkl}}==
543

edits