Questions tagged [binary]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
6 votes
4 answers
184 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. ...
user avatar
  • 65
0 votes
0 answers
61 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|. <...
user avatar
  • 65
2 votes
1 answer
67 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, ...
user avatar
  • 61
2 votes
1 answer
39 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: ...
user avatar
  • 45
4 votes
2 answers
135 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 ...
user avatar
  • 61
0 votes
1 answer
98 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: ...
user avatar
1 vote
3 answers
91 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. ...
user avatar
  • 113
0 votes
0 answers
33 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 ...
user avatar
  • 113
2 votes
1 answer
42 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 ...
user avatar
  • 6,630
12 votes
3 answers
446 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 ...
user avatar
  • 123
1 vote
1 answer
48 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 ...
user avatar
  • 485
1 vote
0 answers
66 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 ...
user avatar
  • 1,723
0 votes
0 answers
32 views

Making a binary number $n$ that must contain $k$ times a $1$ such that `k==GCD[n,IntegerReverse[n]]`

Well, I am trying to code the following thing in Mathematica: I have a binary number $n$ that must contain $k$ times a $1$. So for example: when $k=5$ the following binary numbers does fit the rule: $$...
user avatar
  • 1,723
4 votes
1 answer
230 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 ...
user avatar
  • 271
2 votes
1 answer
113 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 ...
user avatar
  • 23
4 votes
1 answer
104 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 ...
user avatar
  • 271
0 votes
1 answer
115 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:= ...
user avatar
  • 409
11 votes
1 answer
320 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. ...
user avatar
  • 12.3k
5 votes
1 answer
149 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:...
user avatar
  • 1,556
2 votes
1 answer
171 views

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

I have a file which contains the following binary data: ...
user avatar
  • 8,105
6 votes
1 answer
176 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: ...
user avatar
  • 609
4 votes
2 answers
138 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 ...
user avatar
  • 117
0 votes
0 answers
29 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 ...
user avatar
  • 465
0 votes
1 answer
53 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 ...
user avatar
  • 465
1 vote
0 answers
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 ...
user avatar
  • 1,578
4 votes
4 answers
252 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.
user avatar
  • 117
2 votes
3 answers
185 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: ...
user avatar
  • 23
0 votes
2 answers
60 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 ...
user avatar
  • 1
0 votes
0 answers
40 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 ...
user avatar
  • 180
1 vote
1 answer
201 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 ...
user avatar
11 votes
7 answers
2k 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: ...
user avatar
1 vote
1 answer
107 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 ...
user avatar
1 vote
1 answer
89 views

How to understand and use bit operation for programming

I got the following code using bit operation from here: ...
user avatar
6 votes
0 answers
115 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 ...
user avatar
  • 147
1 vote
0 answers
83 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 ...
user avatar
  • 3,720
12 votes
0 answers
463 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: ...
user avatar
  • 613
1 vote
1 answer
157 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 ...
user avatar
  • 1,269
5 votes
0 answers
66 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 ...
user avatar
  • 224k
3 votes
1 answer
331 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 ...
user avatar
4 votes
1 answer
112 views

Something is wrong with the implementation of the ThueMorse function

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-...
user avatar
  • 763
7 votes
4 answers
816 views

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? ...
user avatar
  • 123
3 votes
0 answers
266 views

How to import a binary data generated by Fortran? [closed]

I have a unformatted binary data file generated by gfortran. However, when the binary data is imported by Mathematica, a correct result is not obtained. This is my fortran code: ...
user avatar
2 votes
2 answers
127 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 "$...
user avatar
1 vote
2 answers
238 views

Number of contiguous ones of an element in a 2d binary array

I have a 2d binary array of 0s and 1s. I select an element and would like to know how many 1s are in the contiguous cluster that includes the selected point. If the selected element is 0, the answer ...
user avatar
0 votes
1 answer
551 views

Using the binary search algorithm in a sorted grid

I want to get a mathematica code for binary search algorithm applied to a sorted grid containing integers. For example, given f[k_,x_]= x^2 + k x + k - 2 where <...
user avatar
4 votes
1 answer
1k views

How to read this dataset with .dat and .r64 files?

I stumbled upon the European Data Incubator project, and wanted to play around with some of their data. I'm trying to open this dataset, which contains a bunch of ...
user avatar
2 votes
0 answers
378 views

Converting hex string to ByteArray

With blockchain support, it should finally become straightforward to convert string hashes to ByteArray, but I still can't figure out the canonical Wolfram way of ...
user avatar
  • 7,085
2 votes
1 answer
196 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 ...
user avatar
4 votes
4 answers
786 views

How to total the amount of zeros in a binary matrix

I have a 150 by 300 binary matrix. I would like to find the total amount of zeros in the matrix. I've been consulting online documentation for support, but am unable to use the "count" function ...
user avatar
  • 281
1 vote
0 answers
70 views

Efficiently transform sequentially generated integer matrices into boolean matrices

Assume you have a list of 5 numbers, eg L = {14, 7, 11, 14, 0};. Now, what you want to do with this list, is to transform each entry into eg a binary list, using <...
user avatar
  • 3,980