Next: , Previous: , Up: stdlib bytevector   [Index]


5.2.7 Operations on 64–bit integers

Procedure: bytevector-u64-ref bytevector k endianness
Procedure: bytevector-s64-ref bytevector k endianness
Procedure: bytevector-u64-native-ref bytevector k
Procedure: bytevector-s64-native-ref bytevector k
Procedure: bytevector-u64-set! bytevector k n endianness
Procedure: bytevector-s64-set! bytevector k n endianness
Procedure: bytevector-u64-native-set! bytevector k n
Procedure: bytevector-s64-native-set! bytevector k n

k, …, k+7 must be valid indices of bytevector.

For bytevector-u64-set! and bytevector-u64-native-set!, n must be an exact integer object in the interval 0 <= n <= 2^{64}-1.

For bytevector-s64-set! and bytevector-s64-native-set!, n must be an exact integer object in the interval -2^{63} <= n <= 2^{64}-1.

These retrieve and set eight–byte representations of numbers at indices k, …, k+7, according to the endianness specified by endianness. The procedures with u64 in their names deal with the unsigned representation; those with s64 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 8.

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-u64-ref b 8 (endianness little))
⇒ 18302628885633695743
(bytevector-s64-ref b 8 (endianness little))
⇒ -144115188075855873
(bytevector-u64-ref b 8 (endianness big))
⇒ 18446744073709551613
(bytevector-s64-ref b 8 (endianness big))
⇒ -3