Skip to main content

Questions tagged [binary]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
110 views

how to convert a decimal fractional number to binary with given number of digits after the binary point?

Given 0.4, the binary form is 0.0110011001(with 10 digits after ".") and 0.011001100110011001100110(with 24 digits after ".") without rounding. Is there any function that can do ...
metroidman's user avatar
1 vote
0 answers
61 views

How to Parse Binary .STL File Created on Ancient 32-bit Architecture

Import[fileName,"STL"] returns $Failed The file format is so simple that one can calculate the number of triangles in the file by counting the number of BinaryReads to reach EndOfFile. https:...
Stewart Dickson's user avatar
0 votes
1 answer
87 views

Binary algorithm for finding the range of elements

Consider a sorted list of real numbers listz and some boolean condition condition that involves these numbers: ...
John Taylor's user avatar
  • 5,827
0 votes
1 answer
61 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 ...
skyfire's user avatar
  • 477
1 vote
1 answer
161 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 ...
Alexei Boulbitch's user avatar
1 vote
4 answers
972 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 ...
Richard's user avatar
  • 93
2 votes
3 answers
141 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 ...
Georgy's user avatar
  • 305
2 votes
1 answer
139 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, ...
Kirill Vasin's user avatar
  • 1,245
5 votes
2 answers
182 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 ...
Klangen's user avatar
  • 1,009
9 votes
3 answers
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 ...
Adam's user avatar
  • 3,956
3 votes
1 answer
307 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 ...
kernel density's user avatar
1 vote
1 answer
140 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 ...
Fabio Sattin's user avatar
9 votes
6 answers
224 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. ...
J0ta's user avatar
  • 115
0 votes
0 answers
85 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|. <...
J0ta's user avatar
  • 115
2 votes
1 answer
73 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, ...
peter21's user avatar
  • 61
2 votes
1 answer
103 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: ...
djxdddd's user avatar
  • 45
4 votes
2 answers
344 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 ...
peter21's user avatar
  • 61
0 votes
1 answer
590 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: ...
EconomicsandMathematica's user avatar
1 vote
3 answers
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. ...
drorhun's user avatar
  • 123
0 votes
1 answer
59 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 ...
drorhun's user avatar
  • 123
2 votes
1 answer
54 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 ...
Ted Ersek's user avatar
  • 7,134
12 votes
3 answers
572 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 ...
Heiko's user avatar
  • 123
1 vote
1 answer
87 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 ...
1729taxi's user avatar
  • 777
1 vote
0 answers
117 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 ...
Jan Eerland's user avatar
  • 2,001
4 votes
1 answer
269 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 ...
John Doe's user avatar
  • 279
2 votes
1 answer
146 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 ...
Daniela's user avatar
  • 33
4 votes
1 answer
122 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 ...
John Doe's user avatar
  • 279
1 vote
3 answers
255 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:= ...
Marion's user avatar
  • 429
11 votes
1 answer
446 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. ...
Alan's user avatar
  • 13.7k
5 votes
1 answer
627 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:...
Xuemei's user avatar
  • 1,616
2 votes
1 answer
488 views

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

I have a file which contains the following binary data: ...
user13892's user avatar
  • 9,443
7 votes
1 answer
930 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: ...
Tschibi's user avatar
  • 877
4 votes
2 answers
191 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 ...
SPJ's user avatar
  • 159
0 votes
0 answers
39 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 ...
skyfire's user avatar
  • 477
0 votes
1 answer
97 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 ...
skyfire's user avatar
  • 477
1 vote
0 answers
46 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 ...
apt45's user avatar
  • 1,658
4 votes
4 answers
294 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.
SPJ's user avatar
  • 159
2 votes
3 answers
245 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: ...
almagy's user avatar
  • 23
1 vote
2 answers
80 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 ...
Fvwm's user avatar
  • 11
0 votes
0 answers
45 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 ...
atlasgeo's user avatar
  • 180
1 vote
1 answer
399 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 ...
Walter Lars Lee's user avatar
11 votes
7 answers
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: ...
KHAAAAAAAAN's user avatar
1 vote
1 answer
237 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 ...
Mwen Rele's user avatar
1 vote
1 answer
100 views

How to understand and use bit operation for programming

I got the following code using bit operation from here: ...
A little mouse on the pampas's user avatar
6 votes
0 answers
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 ...
A postdoc's user avatar
  • 159
2 votes
0 answers
165 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 ...
user5601's user avatar
  • 3,625
12 votes
0 answers
483 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: ...
banone's user avatar
  • 728
3 votes
1 answer
319 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 ...
Diego Olvera's user avatar
1 vote
1 answer
223 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 ...
Ray Troy's user avatar
  • 1,299
5 votes
0 answers
84 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 ...
Szabolcs's user avatar
  • 235k