# Questions tagged [binary]

The tag has no usage guidance.

113 questions
Filter by
Sorted by
Tagged with
55 views

### Colorized hexdump

I have this hexdump command that I am writing to display a nicely printed hexdump into a mathematic grid. I want to be able to specify regions that I can highlight, however I am stuck being only able ...
1 vote
144 views

### How can I Xor two decimal numbers?

I want to take two numbers, say 200 and 101, and transform them into their binary form. Then XOR them together and transform the result back into the decimal form. The result in this case should be ...
1 vote
319 views

### 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 ...
105 views

### How to calculate the rightmost 1 and the leftmost 1 in the binary representation of a large number x?

So I have an integer $x$ between $1$ and $2^{64}$ and I am looking for the fastest way to get the rightmost 1 (the least significant bit or LSB) and the leftmost 1 (the most significant bit, MSB). How ...
127 views

### Parsing HTTP POST request or how to find a string in a byte array

I am a developer of a Mathematica web-server (see TinyWEB). I managed to parse a multipart POST request containing text files, however, it is hard to expand it to any types of binary data like JPEG, ...
178 views

### DigitCount[], but in negative bases

The DigitCount[n,b] function "counts the gives a list of the numbers of $1, 2, \ldots, b-1, 0$ digits in the base-$b$ representation of $n$". I want to ...
1k views

### Convert four bytes to IEEE 754 float

I have some bytes, say bytes=ByteArray@{189,178,61,188}, read from a file with Import[...,"Byte"]. The big endian ...
217 views

### Convert List of integers to Hex

I'm doing some OpenCL computing with Mathematica, I have an SHA256 implementation running on my GPU. It returns a list of uints (64bit, Mathematica mistakenly treats these as signed 64bit ints), how ...
1 vote
128 views

### Importing IDL sav file into Mathematica

I have a rather big (around 400 MB) file written by the IDL (Interactive Data Language) software into its binary format ".SAV" which is a proprietary format, not the spss format expected by ...
202 views

### Row function to join together binary number elements

I am trying to join entries of binary numbers at the lowest level of a nested list, e.g. ...
75 views

### Real to IEEE 754 not working for values -1<x<1

I have written a Module that takes a real number and returns the IEEE 754 floating point binary equivalent. It works fine for values above |1|, but I cannot get it to work for inputs less than |1|. <...
71 views

### Changing values in a list

I am currently working the genetic algorithm, specifically in the mutations part, that takes binary numbers and want to convert some of the values in a string into another value. For example, ...
89 views

### Need help converting decimals to Binary

I am struggling figuring out how to turn decimals between {0,1} to binary. I am currently trying to use RealDigits[] and FromDigits[] For example using: ...
273 views

### Numbers to binary and back

I am struggling on how to create a function that converts a number into binary and then back. I know there is a built-in function about this BaseForm[] but I am ...
500 views

### Algorithm to convert real numbers decimal to binary

Currently trying to write code that converts decimal floats to binary base form (I know BaseForm exists). Currently I'm working with an example that takes 3.3 and converts it: ...
1 vote
113 views

### Converting Binary Values to Points [closed]

I searched a lot for this question but couldn't find a similar question. How can I convert my binary values to points. The output of the code I wrote is below, I wrote my expectation also below. ...
47 views

### How do I get 3 digits binary after calling BaseForm or IntegerDigits [duplicate]

Let's say I have a list called 'solution', I'm converting these numbers into binary form ...
50 views

### How to read doubles from specific location of a large file

I have a 1GB file in a proprietary format that is a mix of ASCII characters and doubles (floating point numbers). I need to read in a sequence of twelve doubles. They are in consecutive bytes of the ...
555 views

### Generating a matrix with specific number of 1's in every row and column

I would like to have a function f(n,k) that generates a random nxn matrix with k elements equal to 1 in each row and column and has an all-zero diagonal, with all other elements equal to 0. In other ...
1 vote
73 views

### Extracting data from binary file without reading the whole file - is this possible? [duplicate]

Suppose I have a binary data file that holds 1 million lists each composed of five integers. i.e. $\{ x1,x2,x3,x4,x5 \}$ Perhaps I am missing something obvious (quite likely) - but if I know I want to ...
1 vote
110 views

### Implementing the Binary GCD algorithm in Mathematica

Well, I have $n\in\mathbb{N}$ and I want to transform $n$ to a binary number which can be done using FromDigits[IntegerDigits[n, 2]]. I want to compute the ...
259 views

### Using Mathematica to derive analytic form of single variable function

I am interested in finding an analytical form of the following function $f(n)$ defined as: $$f(n):=\sum_{\{\bar{K}\}}\prod_{l<j}^{n}e^{ik_lk_j},$$ where $\{\bar{K}\}$ is the full set of binary ...
143 views

### How to separate these circle based on their pixels mean intensity?

I have this image I want to separate green circles from yellow circle in two different images whiteout changing the pixel intensity information. I used the mean intensity ...
113 views

### Binary permutation list code in Mathematica

Given some natural number $N$, I am interested in the set of all binary permutations of length $N$ (with the intention of storing in lists depending on how many $1$'s appear in each permutation). My ...
1 vote
234 views

### Minimizing a function over a bounded domain with binary variables

I want to minimize the following function: $$f(m,n)= \sum_{i=1}^N\Big\{ \alpha_i(x_i-m)^T(x_i-m) \Big\} + \sum_{i=1}^N\Big\{\beta_i (x_i-n)^T(x_i-n) \Big\}$$ where $m,n$ are all 2-d vectors:  m:= ...
400 views

### What is the relationship between the Wolfram executables? Where is this documented?

The relatively new wolframscript now accompanies the traditional math and wolfram binaries. ...
543 views

### Read binary files and separate the 64-bit unsigned integers into certain forms？

I have a binary file where each data is a 64-bit unsigned integer (little endian). For simplicity, let's say the data in testdata.bin file opened in HxD is: namely:...
422 views

### How do I get the data from this binary file? [duplicate]

I have a file which contains the following binary data: ...
734 views

### Convert ByteArray to integer and real values

during the import of a complex file format I handle ByteArray or lists of byte values. While I can easy transform them from one type to each other: ...
187 views

### How to generate the 8^th order symmetric binary matrices whose sum of absolute eigenvalues is 8?

It is needed to generate all 8th order(8 by 8) symmetric binary matrices(of 0's and 1's) such that the sum of the absolute eigenvalues is 8. Listing all the 8th order symmetric binary matrices and ...
38 views

### FindClusters Hamming Distance giving error

I am trying to run FindClusters[hex, DistanceFunction -> HammingDistance[IntegerDigits[#, 2, 8], IntegerDigits[0, 2, 8]] &] over a list of data but I keep ...
95 views

### Import and create a hexdump view of file

How would I go about creating a hexdump type of view of an imported binary file? for example, (format is ...
1 vote
45 views

### Reading product of same ByteArrays

I am handling a huge set of data and I am trying to optimize my code. I have very large expressions to expand and simplify and I've seen that converting the expressions to ByteArrays improves a lot ...
288 views

### Generating all symmetric binary matrices of order up to 7?

I want to create all symmetric binary matrix with order up to 7. Can anybody help in creating this? I want to obtain the subset of all symmetric matrices, with all diagonal entries being zero.
231 views

### Simplifying expressions containing binary variables

Consider an expression with two binary variables, $a,b\in\left\{ 0,1\right\}$, given by $F=(1-a-b)^{3}(1-b)$, with truth table: ...
77 views

### FindMaximum under binary constrains

I'm trying to find a maximum for a function whose variables have binary values (either -1 or 1). The clumsy code for that constraint I use is shown below. There must be a more compact code, and I ...
44 views

### Table Glitch / Error with binary data

I have a large group of binary files that I am loading with binaryList = Table[ BinaryReadList[ paths[[i]], "Byte"], {i, Length@paths}]; specifically ...
1 vote
355 views

### Import OVF 2.0 Vector field files

I'm using a simulation software (mumax3) which outputs OVF_2.0 files. It can either export binary or text files. The binary files are usually much smaller than the text files. I would like to use the ...
3k views

### Find if there are consecutive 1s in a binary representation of a number

Given a list of numbers in decimal form, what is the most efficient way to determine if there are any consecutive 1s in the binary forms of those numbers? My solution so far: ...
1 vote
194 views

### Construct a binary tree where nodes are labeled according to given rule

I want to plot a binary tree in Mathematica where the nodes are labeled according to a given rule. In fact, whether a node has a left child or a right child or both, will be determined by a rule. And ...
1 vote
98 views

### How to understand and use bit operation for programming

I got the following code using bit operation from here: ...
141 views

### Importing a 12 bit array

I have a binary file of 12 bits integers obtained from a camera software. It can produce FITS files from these but the processing time on the large data set I have is excessive. What I have is the ...
145 views

### How to recover plaintext from .MX files?

I need a function to deserialize the contents of an MX source file for reading. We can’t simply use Get because I don’t want to load or run the code, but rather to ...
480 views

### Why does Mathematica consume so much memory when reading binary data?

There are somewhat similar questions on here, but I didn't find a satisfying answer for this case: I import a 1.7 GB binary data file using the following command: ...
288 views

### How to get the bit size (bit length) of an integer? [closed]

Suppose I have the integer 255, so 11111111 is its base 2 (bit) representation and the bit size of 255 is 8. How can I calculate the bit size of a (big) integer in Mathematica? Is there a built in ...
1 vote
212 views

### Why ImportByteArray when generate image from bytes

I was trying to generate an image from a list of bytes so I only had to Import an Image once as I want to store a Base64Encoded ...
74 views

### Does NumericArray always maintain data unmodified?

Suppose that we create a NumericArray using a LibraryLink function, then pass this to another one. Is NumericArray guaranteed to maintain the binary data as it was ...
401 views

### Read NumericArray from a file

Suppose I have a binary file which consists of a list of integer or real numbers. Let's say signed 8-bit integers; so each byte of the file is a single such integer. How can I read it and turn it into ...
While trying to answer this Math.SE question, I believe I found several bugs in Mathematica and Alpha relating to the Thue-Morse sequence. As a quick reminder, the $n^{\rm th}$ element of the Thue-...