# Questions tagged [binary]

10140 questions

1

votes

1

answer

10

Views

### Binary Sequence for activity of a user

I have a binary sequence for the activity period of a user. There is a '0' when he was not active on this day and a '1' when he was. I want to proof if he was active not less than two times a week, so there have to be at least two ones in every 7 positions of the sequence. Can anyone help me to imp...

1

votes

3

answer

2.4k

Views

### dotnet build - get error “could not return the default page '/index.html'”

try to generate my project into exe file, but get error:
before: 'dotnet build -r win10-x86' is ok
after run generated exe, all is ok also:
indows DPAPI to encrypt keys at rest.
Hosting environment: Production
Content root path: C:....\currencyColution\correncyProject\bin\Debug\netcoreapp2.1\win10-x...

-1

votes

0

answer

31

Views

### JSON validation on Java

I want to make validations on the backend side, for a JSON structure received from the client.
JSON example from frontend:
{
'status': {
'type': 'string',
'value': 'test'
},
'validFrom': {
'type': 'number',
'value': '123123123'
},
'customerData': {
'type': 'map',
'value': {
'customerName': {
'type':...

1

votes

1

answer

1.7k

Views

### When I open a docx in hex viewer, can someone explain what i'm seeing

I wanted to learn about what I was looking at when I open a DOCX file in a hexadecimal viewer.
For example:
Hexadecimal is base 16 on a 32bit (DWORD) file?. So I was assuming that starting from right to left you would do:
0*16^0 + 0*16^1 + 6*16^2 + 14*16^3 ...... all the way to the 504B.
But when I...

0

votes

0

answer

6

Views

### Insert bytes into file using shell

I would like to use a linux shell (bash, zsh, etc.) to insert a set of known bytes into a file at a certain position. Similar questions have been asked, but they modify in-place the bytes of a file. These questions don't address inserting new bytes at particular positions.
For example, if my file ha...

7

votes

3

answer

145

Views

### C++ Get binary value of a buffer

I'm really sorry for the wording of the question, it's a bit confusing.
So lets say I have a buffer:
char buffer[4] = {0, 0, 2, 0};
if we convert it all to binary, we get one 32 bit unsigned int:
00000000 00000000 00000010 00000000
The value of it is 512.
So my question is, how do I get to th...

1

votes

4

answer

40

Views

### Explain the Step by step execution of the recursion code to convert Decimal to Binary in Java

So, this is the code to convert a Decimal number to Binary number using recursion in Java, the code works without any error. But I am confused how does the compiler execute this code, like I was solving it using paper, but I am not able to understand how the compiler takes it and generates the outpu...

1

votes

3

answer

83

Views

### Finding the difference between a negative and positive binary Number

I know that we can represent binary Numbers in several ways, but I am really not sure how to distinguish a positive binary number from a negative one.
If we have the number +13, then its binary representation looks like this:
1101
and its negative representation looks like this:
11101
What I underst...

1

votes

2

answer

53

Views

### Returning the Most Negative Two's Complement Number in C with Bitwise Operators

I have a function in C that should return the most negative two's complement number:
int mostNegTwosComp(void) {
return 0;
}
I am constrained to using a maximum of 4 bitwise operators. These operators include: ! ~ & ^ | + >. How would I go about doing this? Wouldn't the most negative two's comp numb...

1

votes

1

answer

55

Views

### One-line output operator for a binary tree

I wrote a simple binary tree class in C++ and want to add an output operator to it. My first attempt was:
ostream& operator

1

votes

2

answer

46

Views

### The proper way to overload binary operation

I'm new in C++, so, please, go easy on me :)
I've found two different ways to overload binary operator in c++.
The first one (from book 'Object-Oriented Programming in C++', Robert Lafore):
class Distance
{
private:
int value;
public:
Distance() : value(0) {}
Distance(int v) :value(v) {}
Distance o...

1

votes

6

answer

17.5k

Views

### How to find TMax without using shifts

Using ONLY
! ~ & ^ | +
How can I find out if a 32 bit number is TMax?
TMax is the maximum, two's complement number.
My thoughts so far have been:
int isTMax(int x)
{
int y = 0;
x = ~x;
y = x + x;
return !y;
}
That is just one of the many things I have unsuccessfully have tried but I just cant think...

3

votes

1

answer

16

Views

### Is there a way to convert binary data into a data type that will allow ActiveStorage to attach it as an image to my User model

I am hitting an api to get an image that they have stored and use it as the profile pic for our application's users. I'm using Ruby on Rails and ActiveStorage with AWS to attach and store the image. What they send back is this:
{'status'=>'shared', 'values'=>[{'$objectType'=>'BinaryData', 'data'=>'/...

1

votes

2

answer

740

Views

### How to print A binary tree?

how can i send (node.data) from SortTree Class to TreePrinter then used to print A Tree .
import javax.swing.tree.TreeNode;
public class SortTree {
static Node root;
TreePrinter type =new TreePrinter();
class Node{
int data;
Node left, right;
Node(int d) {
data = d;
left = null;
right = null;
}
}
N...

1

votes

2

answer

386

Views

### Smallest element in tree that is bigger than x

If I want to find the smallest element in a tree that is bigger than an element x, would this be a correct way to do it?
class Node {
int data;
Node left, right;
}
Node root;
public Integer successorOf(int x) {
return successorOf(x, root);
}
private Integer successorOf(int x, Node n) {
if (n == nul...

1

votes

1

answer

116

Views

### Is it necessary to convert a data to binary set to calculate similarity (jaccard index)?

I need to calculate jaccard similarity to dataframe below:
df = data.frame(
a=c('1', '1', '1', '1', '2', '2', '2', '3', '3', '4', '4', '4', '4'),
b=c('100', '101', '111', '25841', '111', '101', '106', '101', '108', '100', '30256', '108', '112'))
Is necessary i convert data to binary set? How do thi...

1

votes

1

answer

56

Views

### Binary Node Tree, wrong father and sons

I'm having a hard time printing the following tree:
----------t1:----------
tree:(((1),2,(3)),4,((5),6,(7,(8))))
----------t2:----------
tree:(((1),2,((3),4)),5,(6,(7,(8))))
----------t3:----------
tree:((1),2,(3,(4,(5,(6,(7,(8)))))))
----------t4:----------
tree:((((((((1),2),3),4),5),6),7)...

1

votes

1

answer

18

Views

### Designing data structure which can decrease range in lgn

I was asked in an exercise to design a data structure which can handle the following methods in logarithmic time complexity (lgn):
Insert(x): Inserts x to the data structure
Find(x): Finds if x exists in the data structre
Decrease(x, y): Adds negative value y (y

1

votes

0

answer

111

Views

### How can I detect an overflow in binary multiplication?

I am a little desperate on how to detect an overflow when multiplying two 8-bit signed binary numbers? The result should also have 8-bit.
I multiply them in a microprogram using shift and add instructions. My algorithm works like this in pseudocode for multiplying binary numbers a * b, in addition I...

1

votes

1

answer

63

Views

### Need help on BDDs graphs

I am reimplementing (for fun, a bit of work and a severe case of NIH) a ROBDD library. I would like to have a few 'reference' graphs built by other libraries to compare results [*]
E.g., given the variable order x1 < y1 < x2 < y2, what would be the graph obtained for
(x1 y1) /\ not (x2 y2) /\ (x2...

16

votes

4

answer

31.1k

Views

### Fortran unformatted file format

I don't understand the format of unformatted files in fortran.
For example:
open (3,file=filename,form='unformatted',access='sequential')
write(3) matrix(i,:)
outputs a column of a matrix into a file. I've discovered that it pads the file with 4 bytes on either end, however I don't really understan...

1

votes

0

answer

44

Views

### HTML 5 audio tag, what is the expected encoding?

Can I specify the encoding of the file being received, is it only binary? Can I tell it it's expecting base64 etc?
Example use case :
If your browser doesn't support the 'audio' element, it will display the content here between the opening and closing tags.

1

votes

1

answer

191

Views

### Reading binary file with batch size using boost serialization

I am trying to serialize the class with boost's binary serializer, and loading the binary data with batch size.
I am able to fetch the first 5 records out of 10, and the process is crashing while I am trying to read an another 5 records by re-opening the file and re-setting the file read pointer to...

1

votes

1

answer

275

Views

### convert non balanced binary search tree to red black tree

Is it possible to convert a non balanced BST (the size of the tree is n and the height is h) to RBT in time complexirty of O(n) and space complexity of O(h)?

1

votes

0

answer

24

Views

### in given number x , can i check if x exist in the array with time complexity of log(n)+log(m)?

Given a two-dimensional array sorted in size of NxM so that:
The rows are sorted from left to right - from large to small.
The cols are sorted from up to down - from large to small.
in given number x , can i check if x exist in the array with time complexity of
log(n)+log(m)
?

1

votes

0

answer

53

Views

### Percentage sign binary operator in ggplot R

I used percentage signs in the column names of a data frame. So far, I haven't encountered any disadvantages by doing so.
Now I would like to create a ggplot with my data and get the following error due to the use of percentage signs:
Error in stat_boxplot(geom = 'errorbar') + geom_boxplot() :
non-...

1

votes

1

answer

48

Views

### How to compare the shape of one SortedSet to another in C#

I'm trying to compare the shape (by shape, I mean the shape of the binary tree) of one SortedSet at a certain index of a List of SortedSets against all the rest of the SortedSets in that same List. I've tried to look up ways to compare Binary Trees, but I don't know how to do it with SortedSets inst...

1

votes

1

answer

56

Views

### Writing data from a structure to a file in c#

So I am currently attempting to write data from a structure to a binary file and am not having a ton of luck, I was just wondering if anyone could point me in the right direction of what I may need to implement as most of what I've tried and researched has been unsuccessful. Below is very basic skel...

1

votes

0

answer

38

Views

### Python3.4 packing and format type with struct

I have a binary file which I am trying to recreate by writing data to a new file. The data in it should be stored as 32-bit (4-byte) twos- complement binary integers or as ASCII characters. The first 4 bytes should represent the integer 0, then the next 4 should be the integer 4, the next 4 should b...

1

votes

0

answer

72

Views

### Why are the values incorrect when parsing binary data using python ctype structures?

This binary data is being parsed via a python parser file containing ctype structures. Unfortunately, it is not returning the proper values. Most likely this is because I am not 100% sure how to interpret this data.
This spec outlines how the binary data is organized. I am not 100% sure how to inter...

1

votes

2

answer

358

Views

### Retrieve data from .rec binary file

The question may be naive, but answers could help me.
A measurement is recorded in binary format, with a header that contains all information about the data and the data itself (i.e. a series of doubles).
The measurement data can be exported in csv format from the application, but it takes ages....

1

votes

2

answer

52

Views

### Finding kthSmallestElement in the BST

I am trying to solve the following question from LeetCode:
https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/
The aim is, given a BST, we have to find out the Kth-smallest element in it and return its value.
I could come up with a O(n) time and space solution myself. But anoth...

1

votes

1

answer

40

Views

### Viewing image file bytes

Not looking for help accomplishing anything specific. Looking to understand what is happening. Can anyone explain or point to a source to help me understand? Thank you.
I have a JPEG containing 1 pixel with a (0,0,0) RGB value.
Opening in a text editor shows 631 hexadecimal pairs. The 1st pair is 'f...

1

votes

0

answer

69

Views

### Binary Tree size function python

I'm a beginner of Python and data structure, I have a problem with designing the binary tree size method, my code and my error are as follows
class BinaryTree:
def get_left(self):
return self.left
def get_right(self):
return self.right
def set_data(self, data):
self.data = data
def get_data(self):
r...

1

votes

0

answer

64

Views

### My binary search on java doesn't count or print the right index values after the search

I am programming a class that when called upon, would search for a specific number using binary search. The program would also print the number of times it searched for a said number, and return the index value. Unfortunately, the index value always returns me a -1, which is the number I set it as w...

1

votes

2

answer

52

Views

### Binary search with process output

Expected output :
If the key is below the mid point
Data : [1, 4, 6, 13, 14, 23, 30, 45, 58, 67, 76, 89, 99]
Input key : 6
Binary Search :
1 step index - 0 : 1, not found !
2 step index - 1 : 4, not found !
3 step index - 2 : 6, founded !!
If the key is greater than mid point
Data : [1, 4, 6, 13, 14...

1

votes

0

answer

88

Views

### How can I send resource to API through Content-Type: application/octet-stream php

I am trying to reproduce this POST https://www.screencast.com/t/OUE1StfLfyP7 in php but I couldn't archive that it works correctly because after downloading the image is not possible to open it
$url = 'https://internal-api-staging-lb.interact.io/v2/contacts/X/documents/fr_FR9.gif';
$data = array('fi...

1

votes

0

answer

21

Views

### Pivoting a large table

I have a very messy table with two kinds of columns, a 'start' point and a 'end' point. Wherever the start point occurs, there is a 1, and wherever the end point occurs, there is a 1. All other cells are filled with zeros, so each row only contains two 1 values. Here's a general idea of what it look...

1

votes

0

answer

381

Views

### Hierarchical logistic regression

I am trying to predict depression by using two quantitative variables and their interaction. However, before I want to see how much variance they explain, I want to control for a few variables.
My plan was to build a logistic regression model:
Depression = Covariates + IV1 + IV2 + IV1:IV2
Unfortunat...

1

votes

3

answer

245

Views

### error: bad operand types for binary operator '=='

Just wanted to do a task in my Book but I don't get why this is wrong.It should say that negative Numbers aren't positive and positive aren0t negative with a Boolean.
This is my Code:
import javax.swing.JOptionPane;
public class Zahlentest {
public static void main(String[] args) {
String eingabe;
c...