Skip to content

Commit

Permalink
Fix uint32_t to uint40_t construction and cast
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngalstyan4 committed May 7, 2024
1 parent bcc27c4 commit 49c681b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/usearch/index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ class usearch_pack_m uint40_t {

public:
inline uint40_t() noexcept { broadcast(0); }
inline uint40_t(std::uint32_t n) noexcept { std::memcpy(&octets[1], &n, 4); }
inline uint40_t(std::uint32_t n) noexcept { std::memcpy(&octets, &n, 4); }

#ifdef USEARCH_64BIT_ENV
inline uint40_t(std::uint64_t n) noexcept { std::memcpy(octets, &n, 5); }
Expand All @@ -811,7 +811,7 @@ class usearch_pack_m uint40_t {
#ifdef USEARCH_64BIT_ENV
std::memcpy(&result, octets, 5);
#else
std::memcpy(&result, octets + 1, 4);
std::memcpy(&result, octets, 4);
#endif
return result;
}
Expand Down

0 comments on commit 49c681b

Please sign in to comment.