Questions tagged [binary]
115 questions
9
votes
2 answers
No builtin function for bitwise rotation?
There appears to be no builtin Mathematica function for bitwise rotation. Is that true?
I suppose I can write my function:
ROR[x_, k_] := FromDigits[RotateRight[IntegerDigits[x, 2, 32], k]]
Obviously this will be a lot more inefficient than a…
Tyler Durden
- 4,090
- 14
- 43
8
votes
4 answers
BitNot does not flip bits in the way I expected
Can anyone explain why the last result in these statements is not the bit-flipped version of arr?
(Debug) In[189]:= arr = {0, 0, 1, 0, 0, 0, 1, 0}
(Debug) Out[189]= {0, 0, 1, 0, 0, 0, 1, 0}
(Debug) In[190]:= FromDigits[%, 2]
(Debug) Out[190]=…
bc888
- 133
- 4
1
vote
4 answers
Converting two 8-bit integers into a single 16-bit integer
I have a situation where I have a pair of integers {a, b} where a and b are in bytes from a binary file. I want to combine these two 8-bit representations to a single 16-bit one. I am struggling to see how to do this.
Looking on the web suggests…
Richard
- 93
- 3
1
vote
1 answer
How to understand and use bit operation for programming
I got the following code using bit operation from here:
lis = Complement[Range[0, 15], {7, 14, 15}]
ans = Tuples[lis, 3] //
Select[#,
BitAnd[#1, #2, #3] == 0 && BitAnd[4 #1, 2 #2, #3] == 0 &&
BitAnd[#1, 2 #2, 4…
A little mouse on the pampas
- 5,760
- 2
- 13
- 40
1
vote
0 answers
How can I import Real16 binary data? BinaryReadList doesn't work
How can I import Real16 binary data? BinaryReadList doesn't work:
tmp = BinaryReadList[
filename, {"Real16", "Real16",
"Real16", "Real16"}];
BinaryReadList::format: "\!\(\"Real16\"\) is not a recognized binary format."
Look at spec:…
Vasily
- 31
- 2