Questions tagged [binary]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
27
votes
3answers
3k views

Reading periodic elements from a large file

I have a large binary data file (big endian) with 100+ million "rows" of 11 elements, combination of floats and integers. This is the format: ...
20
votes
6answers
2k views

Graph from binary matrix (not adjacency) respecting the original matrix positions

I have a binary matrix. My objective is to connect every close (without "jump") elements with value equal to 1, but I must keep the point positions, just like it's shown at the image. Can somebody ...
21
votes
1answer
810 views

Faster binary Hamming weight for big integers?

While working on an answer to Count the sequences in an array I found that DigitCount was the bottleneck in my code when used as ...
5
votes
1answer
234 views

Decoding GZIP encoded Body, BodyBytes (ByteArray) and BodyBytesArray from URLRead

When calling the Stack Exchange API v2.2 using the new (Mma11) function URLRead we get a GZIP encoded Body in alternative formats: ...
19
votes
2answers
2k views

Import Fortran unformatted binary

I have an unformatted binary file generated using the Compaq Visual Fortran compiler (big endian). Here's what the little bit of documentation states about it: The binary file is written in a ...
9
votes
2answers
633 views

How does Mathematica decide that Log[2,8] is integer?

At school we learned that $\log_b(x)=\log(x)/\log(b)$, which is implemented in Mathematica as Log[b, x], but the results are different. ...
7
votes
1answer
349 views

HMAC implementation in pure Mathematica

I am trying to implement the HMAC algorithm in Mathematica. The algorithm is a relatively simple way of signing messages with a key. Here is some pseudocode from Wikipedia: My attempt: ...
1
vote
2answers
92 views

Command to change binary mlf terms into Subscripted mlf terms?

I express multilinear functions in the following format. Is there any ready command to convert them to multilinear functions easily? Input ...
7
votes
2answers
1k views

How to do binary calculation?

For example, $a=0.10101$ in binary representation. Then how to calculate $a^2$ directly in mathematica? Is there any function turning binary into decimal? I only found its inverse...
16
votes
1answer
468 views

How is the mysterious Raw function used?

I have never seen an example use for the mysterious Raw function: Raw[h, "hexstring"] constructs a raw data object with head h, and with contents ...
22
votes
2answers
273 views

BitShiftRight produces incorrect results in Version 10

Bug introduced in 10.0.0 and fixed in 10.0.2 With Mathematica 10 for Mac, BitShiftRight works properly on lists of up to 100000 numbers, but appears to give ...
12
votes
1answer
2k views

How to read 32-bit *IBM* (not IEEE) floating point values from a binary file?

I am trying to read a binary file. This file records seismic data. Basically its first 3600 bytes are for the general file information, following are for seismic traces, each begins with 240 bytes for ...
7
votes
3answers
339 views

Reading a file as a ByteArray?

I want to read in large files as byte strings. Import[..., "Byte"] yields a list of Integers that takes up much more space (16 times more) than the file. ...
10
votes
5answers
889 views

Substitute some 1s with 0s in random list

How is it better to substitute list of random combination of 1 and 0 (binary image) so that only first (or central) instance of 1 left in each group. ...
9
votes
2answers
899 views

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: ...
4
votes
1answer
650 views

Importing FITS file from HEALPix

I am trying to read FITS file created by HEALPix software. The file contains a spherical map of a scalar field. There is the online support on how to use the file in IDL, but not for Mathematica. I ...
3
votes
1answer
770 views

Binary file gymnastics

I have an unformatted binary file generated by fortran 77 and i want to import it in Mathematica. The file is formed by 5 data arrays with double precission float numbers. The problem is that seems ...
2
votes
2answers
95 views

Listing all monotone increasing binary digits

For $n=5$, I have $32$ binary digits and for this there are $2^{32}$ combinations. Out of this many, the interesting ones (i.e., the ones that have monotone increasing binary digits) are only about "$...
2
votes
1answer
137 views

Generate a prime number in a range with fixed $n$ most significant bits

I'm new to Mathematica so my question might be trivial. How do I generate a $200-bit$ prime with the condition that the 10 most significant bits in its binary representation are equal to some binary ...