Next: stdlib bytevector integers 32, Previous: stdlib bytevector integers, Up: stdlib bytevector [Index]
k must be a valid index of bytevector; so must k+1.
For bytevector-u16-set! and bytevector-u16-native-set!,
n must be an exact integer object in the interval 0 <= n <=
2^{16}-1.
For bytevector-s16-set! and bytevector-s16-native-set!,
n must be an exact integer object in the interval -2^{15} <=
n <= 2^{15}-1.
These procedures retrieve and set two–byte representations of numbers
at indices k and k+1 according to the endianness
specified by endianness. The procedures with u16 in their
names deal with the unsigned representation; those with s16 in
their names deal with the two’s–complement representation.
The procedures with native in their names employ the native
endianness, and work only at aligned indices: k must be a multiple
of 2.
The ...-set! procedures return unspecified values.
(define b
(u8-list->bytevector
'(255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 253)))
(bytevector-u16-ref b 14 (endianness little)) ⇒ 65023
(bytevector-s16-ref b 14 (endianness little)) ⇒ -513
(bytevector-u16-ref b 14 (endianness big)) ⇒ 65533
(bytevector-s16-ref b 14 (endianness big)) ⇒ -3
(bytevector-u16-set! b 0 12345 (endianness little))
(bytevector-u16-ref b 0 (endianness little)) ⇒ 12345
(bytevector-u16-native-set! b 0 12345)
(bytevector-u16-native-ref b 0) ⇒ 12345
(bytevector-u16-ref b 0 (endianness little)) ⇒ unspecified
Next: stdlib bytevector integers 32, Previous: stdlib bytevector integers, Up: stdlib bytevector [Index]