Comments (3)
Is this an endianess problem?
let data: Vec<u8> = vec![0b0000_0000, 0b1111_1111];
let slice = data.view_bits::<Msb0>();
info!("{:04b}", slice[6..10].load::<u64>());
is printing 1100
instead of 0011
.
I work around this with a loop (read until word boundary, shift subslice to the left, continue), but that means I have to do sign extension manually.
Bug or a feature?
from bitvec.
Ran your numbers, in your case it does not look like an endianess problem, and rather like a generic "reads across word boundaries" problem. I guess what happens is
- bitvec reads from the start position until the end of the first word (
00_0111
)- this value is zeroextended to
0000_0111
(aka0x7
) and appended to the output
- this value is zeroextended to
- bitvec reads the remaining bits from the second word (
01
)- this value is shifted by 6 to
0100_0000
(aka0x80
), because the bitvec ended 6 bits before the end of the current word, and the result is appended to the output
- this value is shifted by 6 to
@myrrlyn could you clarify what the expected output is? I guess there must be tests covering reads across word boundaries, therefore this behaviour might be intended (?)
from bitvec.
Related Issues (20)
- Use #[track_caller] attribute HOT 2
- Dead documentation link HOT 4
- `bitvec` contains unsound global state HOT 4
- `chunks_exact_mut()` occasionally doesn't return the last chunk when `step_by()` is involved
- Difference between `BitVec` and `BitVec<T, O>`? HOT 1
- `copy_within` panics on empty range
- `bitarr!` macro link incorrect
- Implement `BitStore` for signed integer types
- impl `TryFrom<BitVec>` for `BitArray`
- How to convert bitvec to slice? HOT 1
- Build for STM32 (no_std, thumbv7m-none-eabi) - no global memory allocator HOT 1
- Regarding the safety of `chunks_mut(...).remove_alias()` HOT 1
- `BitSlice::shift_start` and `BitSlice::shift_end` argument bounds incorrectly documented
- Incorrect handling of end index in BitVec::extend_from_within
- Implement `Send` for `BitValIter`
- How to "not" an entire `BitVec` in place? HOT 1
- Example of zero-initialized BitVec?
- Cargo check failed with error: could not compile `bitvec` (lib) HOT 2
- crate doesnt compile on arduino HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitvec.