﻿ Binary_It technology blog_ Programming technology Q & A「QuestionBank」
QuestionBank

### The shortest Binary sequence to cover Dec numbers 0-99

Consider the set of strings S that contains the binary representation of the numbers 0 to 99. What is the shortest string T such that every element of S is a substring of T?

### I want to find the binary operations that transform an input to an output

Given the input and the output: Input Output 10011100 10010100 10000100 00000000 11111100 10000100 10000011 00000011 10100010 10100010 Are there any operations that can be performed on the rows / cols to get the result? For example, my best try was ((Y AND NOT Y-1) XOR (Y AND NOT Y+1)) OR ((X AND NOT X-1) XOR (X AND NOT X+1)) When no row/col exist, it is assumed to be false. A demonstration of my try: For Y: (Y AND NOT Y-1) XOR (Y AND NOT Y+1) = 10011100 00011000

### Convert non terminating binary number to decimal

I don't know how to convert a non terminating binary number(fraction) to decimal . Can anybody guide me how to do with an example?

### Binary Can HttpClientCodec/HttpServerCodec and HttpObjectAggregator be removed after websocket handshake completes?

I'm in the process of load testing a high performance websocket gateway application which supports 100K+ client websockets. The requests are ALL Binary websocket messages and use our own Codec go to/from byte[] and our POJO. The application is using Netty 4.0.12 on JDK 1.7.0_45. I would like to make the websocket channel pipeline as efficient as possible to provide the maximum throughput with the least CPU utilization. The first thought is to remove any unnecessary handlers. The second wi

### Binary How many user settings can be stored in 4 bytes?

I have limited storage being 2 x 2 bytes. I need to store as many (On/Off) user preferences within this byte space as possible. My calculation so far is a total of 20 user settings by incrementing by a multiple of 2 e.g. First 2 Byte space Option A ON = 1 Option B ON = 2 Option C On = 4 Option D On = 8 Option E On = 16 Option F On = 32 Option G On = 64 Option H On = 128 Option I On = 256 Second 2 byte space: Option J On = 1 K=2 L=4 M=

### Binary Bitwise operation: fitsBits function

I have seen a few other implementations of this function on this site, but I'm curious if someone can help me figure out why this implementation isn't working: //fitsBits: return 1 if x can be represented as an n-bit, two's complement integer. //1<=n<=32 //Examples: fitsBits(5,3)=0, fitsBits(-4,3)=1 //legal ops: ! ~ & ^ | + << >> //Max ops: 15 int fitsBits(int x, int n) { int mask = ~(1<<31); return !(((x>>1)&mask)>>(~(~n+2)+1)

### Binary Interpret PNG pixel data

Looking at the PNG specification, it appears that the PNG pixel data chunk starts with IDAT and ends with IEND (slightly clearer explanation here). In the middle are values that don't make sense to make sense to me. How can I get usable RGB values from this, without using any libraries (ie from the raw binary file)? As an example, I made a 2x2px image with 4 black rgb(0,0,0) pixels in Photoshop: Here's the resulting data (in the raw binary input, the hex values, and the human-readable ASCII)

### binary conversion using 3 figures system 0,1,2

Suppose system is evolved by extraterrestrial creatures having only 3 figures and they use the figures 0,1,2 with (2>1>0) ,How to represent the binary equivalent of 222 using this? I calculated it to be 22020 but the book answers it 11010 .how this.Shouldn't i use the same method to binary conversion as from decimal to binary except using '3' here ???

### how to convert a fraction like (2/3, or 5/7) to binary?

I know how to convert a fraction like (1/4, or 1/8) to binary number because this fraction can also be represented by 0.25, 0.125, but I'm confused about how to convert fraction like 5/7. Thank you.

### Binary vhdl to verilog bintobcd converting

Hello guys I am trying to translate following vhdl code to verilog however it does not work even if they look like pretty same. I get no errors however it is not working with verilog one but works with vhdl one. Can you guys please help me to work out this problem. : library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.std_logic_unsigned.all; use ieee.numeric_std.all; entity binbcd8 is port( b: in unsigned(7 downto 0); p: out unsigned(9 downto 0) ); end binbcd8; architecture Behavioral of binb

### Binary 32-bit int struct bits don't seem to match up (nodejs)

I have a file that defines a set of tiles (used in an online game). The format for each tile is as follows: x: 12 bits y: 12 bits tile: 8 bits 32 bits in total, so each tile can be expressed as a 32 bit integer. More info about the file format can be found here: http://wiki.minegoboom.com/index.php/LVL_Format http://www.rarefied.org/subspace/lvlformat.html The 4 byte structures are not broken along byte boundaries. As you can see x: and y: are both defined as 12 bits. ie. x is store

### Binary How does a computer turn a string of ASCII into a signed or unsigned number?

For example if I type: -6 Through what mechanism is that turned into: 1010 Would it be hardware based or somewhere in the kernel?

### Binary What is “2's Complement”?

I'm in a computer systems course and have been struggling, in part, with Two's Complement. I want to understand it but everything I've read hasn't brought the picture together for me. I've read the wikipedia article and various other articles, including my text book. Hence, I wanted to start this community wiki post to define what Two's Complement is, how to use it and how it can affect numbers during operations like casts (from signed to unsigned and vice versa), bit-wise operations and bit-sh

### Binary Can a coset leader in standard array have weight equal to the minimal distance of a code?

I would like to ask about constructing a standard array for a binary C code [5,2,2]. The number of rows should be q^(n-k) - in this case = 8. But I can make only 5 rows by choosing coset leader of weight 1 (one of the coset leaders produces same vectors as the other one). I tried to choose coset leader of weight 2, equal to the minimal distance of C. This produced completely new vectors, but I am not sure if I can use it since the weight of this coset leader is not strictly smaller than the mini

### Binary What is “2's Complement”?

I'm in a computer systems course and have been struggling, in part, with Two's Complement. I want to understand it but everything I've read hasn't brought the picture together for me. I've read the wikipedia article and various other articles, including my text book. Hence, I wanted to start this community wiki post to define what Two's Complement is, how to use it and how it can affect numbers during operations like casts (from signed to unsigned and vice versa), bit-wise operations and bit-sh

### 1x10^49 in decimal - how binary bits is that and how would you convert it to binary?

I've encountered a website that uses a 50-digit decimal integer ID in a URL query string, which seems a little excessive. The smallest 50-digit decimal number is 1.0 x 10^49, otherwise known as: 1000000000 0000000000 0000000000 0000000000 0000000000 How many bits would the binary representation contain? How would you approach converting such a large decimal number to binary, taking into consideration the range limit of unsigned 32-bit-integer or 64-bit integers? I ask out of pure programm

### Binary Bit operation question

Is there a bit operation or a series of bit operations that would give me the following result? I'll show what I want by using examples. Note that the length of each bit string is irrelevant: 1) 100000 100000 ------ 011111 2) 000000 000000 ------ 000000 3) 100000 000000 ------ 000000 4) 000100 000100 ------ 111011 5) 100100 100100 ------ 011011 6) 100100 000100 ------ 111011 7) 010101 101010 ------ 000000 8) 111111 111111 ------ 000000 So, the idea is that if anywhere i

### Binary Returning cancel value to startup execution file with hex values

I'm editing the startup execution file of a program to remove an error message and automatically return the value of the "cancel" button that you would press if the message was there. I've found the error message in the hex file where its W.R.I.T.T.E.N. .L.I.K.E. .T.H.I.S., I'm guessing because '.' is the escape key in the program so that it is interpreted as text. I then opened up the file in visual basic and discovered its hexidecimal key was 10160 and I changed the value in the file to 00 i

### cannot execute binary file

I have a binary executable that's a part of an academic software package I've downloaded. I can't seem to get it to run, and I don't have access to the source code. I've tried the following things. Any thoughts? Many thanks. \$ chmod +x random_cell \$ ./random_cell -bash: ./random_cell: cannot execute binary file \$ file random_cell random_cell: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped \$ ldd random_cell random_c

### Is the most significant decimal digits precision that can be converted to binary and back to decimal without loss of significance 6 or 7.225?

I've come across two different precision formulas for floating-point numbers. ⌊(N-1) log10(2)⌋ = 6 decimal digits (Single-precision) and N log10(2) ≈ 7.225 decimal digits (Single-precision) Where N = 24 Significant bits (Single-precision) The first formula is found at the top of page 4 of "IEEE Standard 754 for Binary Floating-Point Arithmetic" written by, Professor W. Kahan. The second formula is found on the Wikipedia article "Single-precision floating-point format" under s

### How can one optimally store decimal digits in binary?

I don't need this for anything, but I was just curious about it. The Wikipedia article about QR codes says that storing one decimal number takes 3⅓ bits per digit. Obviously you can't have a third of a bit, so I assume this is the average number of bits it takes to store any given digit. Two questions: Is it true that you can store decimal digits in 3⅓ bits, on average? True or not, how can you store decimal digits in binary optimally?

### What's the absolute minimum a programmer should know about binary numbers and arithmetic?

Although I know the basic concepts of binary representation, I have never really written any code that uses binary arithmetic and operations. I want to know What are the basic concepts any programmer should know about binary numbers and arithmetic ? , and In what "practical" ways can binary operations be used in programming. I have seen some "cool" uses of shift operators and XOR etc. but are there some typical problems where using binary operations is an obvious choice. Please give pointer

### Binary Addition. Is it overflow?

Binary values are in 2s Complement form. If I am to add 110001 (-15) and 101110 (-18), and the answer has to be stored in a 6-bit integer, is this an underflow/overflow.

### Binary Need help with pseudocode please

Given a binary number calculate the maximum block. For ex: Binary representation = 11111 Maximum block length = 5 Binary representation = 10111011 Maximum block length = 3 max block means the number of consecutive 1's or 0's. So 00010000 would have a max block of 4 Above are the only 2 examples my professor gave. "Compute the maximum block length of the binary representation." This is what he said. I'm assuming this includes 0s as well. I really don't know how to go about it. This is what I

### Binary How does a computer store decimal point values?

I have a few questions: Computers only use 1s and 0s to represent numbers. Then how does it represent a decimal point like 5.512. The computer doesn't know whether we are entering an ASCII value or just a random binary for it to process. In earlier days, people used to program using hex and binary. How would they achieve in outputting a character on the screen. Apart from that how does the computer understand that 65(decimal) is not a number but a capital A?

### generating a binary sequence

I need to generate a binary sequence of keys where each key is of length 'x',and each key is generated by a specific operation on the previous key. So assuming the key length to be 3,I should be able to generate a sequence as(illustration): 001 010 100 011 ..... Each key has to be derived by some bit operation on the previous key,till we have exhausted all possible permutations for that specific key length. Since I am a newbie on bit operations - is this a possible operation;and how do we ge

### What does the error: invalid operands to binary expression ("double" and double") mean?

Line 55: where i have written "V=(pow(vx,2)+pow(vy,2))^0.5;" i have the error:invalid operands to binary expression ("double" and double"). What does this mean? Help please ! int main() { FILE *fp, *fopen(); fp=fopen("Orbit2", "w"); double M,G,y0,vx,vy,x,y,h,t,T,m,V, positionx,positiony,velocityx,velocityy,energy,kinetic,potential; G=6.67*pow(10,-11); h=1000; m=7.345*pow(10,22); t=0; M=1.99*pow(10,30); y=0; y0=0; x=1.5*pow(10,11); vx=0; vy=22350; energy=kinetic+potential; T=t+h; for (T=0;

### Binary confusion in MIPS storing bits,

hi im trying to store a bit into a temp. register. Am i doing this correctly? and while i am at it, i am trying to see how many 1's are in the binary forms of a decimal number (0-16) am i doing this right? here is the chunk of code that matters, the rest works fine(just output and what not) # for (i = 0; i <= 16; i++) li \$s0, 0 # i = 0 li \$s3, 0 #constant zero li \$s4, 0 #i-2=0 bgt \$s0, 16, bottom top: # calculate n from i # Your part starts here sb \$t1, (\$s0) #store LSB from number i in

### Binary Recode the same value pattern for all variables in Stata

In my dataset, I have a bunch of Yes/No type variables. For some reason, "Yes" is coded as 1 and "No" is coded as 2 instead of 0. Now I want to recode 2 to 0 based on the value label "No". How can I do it without having to check and recode every single one? There are some complications: Each of these dummies has a value label sharing the dummy's name instead of sharing a "yesno" value label. Therefore, I can't simply loop through all variables that have a "yesno" value label. There might be

### Binary Julia: Base function 10,000x quicker then similar function

I'm playing around with the decimal to binary converter 'bin()' in Julia, wanting to improve performance. I need to use BigInts for this problem, and calling bin() with a bigInt from within my file outputs the correct binary representation; however, calling a function similar to the bin() function costs a minute in time, while bin() takes about .003 seconds. Why is there this huge difference? function binBase(x::Unsigned, pad::Int, neg::Bool) i = neg + max(pad,sizeof(x)<<3-leading_zer

### why is byte_size of huge number in erlang binary is 1?

In erlang, how come byte size of huge number represented as binary is one? I'd thought it should be more? byte_size(<<9999999999994345345645252525254524352425252525245425422222222222222222524524352>>). 1

### Mask certain file paths in binary files

I have a binary file containing some file paths. If the path starts with a certain string, the rest of the file path [\x20-\x7f]+ should be masked, leaving the general structure and size of the file intact! So with a list of paths to search for is this: /usr/local/bin/ /home/joe/ Then an occurrence like this in the binary data: ^@^@^@^@/home/joe/documents/hello.docx^@^@^@^@ Should be changed to this: ^@^@^@^@/home/joe/********************^@^@^@^@ What is the best way to do this? Do sed

### Understanding characters in a binary file

I am reading a binary file written in 16bits (little endian and signed). I successfully read the file and got the good values from the conversion from bytes to integers. But there are some characters that I don't understand, so I hope that someone can explain me it :) b'\xff\xff' gives me -1 which is good and I understand that \x indicates a hexadecimal character escape. b'\x00\x00' gives 0, logic. b'v\x1d' gives 7542, which is the good value (I know it because I know the value that I should g

### How do I convert 234.35 into Binary?

I need to convert the above into Binary. I'm at a loss here. Can you include full information on how you got the answer too?. Step by step would be great!

### Flatten a binary tree to list (ordered)

I am trying to implement an algorithm that takes a tree as input and returns a list with all of the values in the correct order (top to bottom, each row left to right) but I am having trouble with it. The easy way to do it unordered is to reduce the entire list where each node gets appended to the accumulated list. This is the code I wrote to reduce a tree (written in elixir) where each node has a left and right branch which can be another node or nil: def reduce(nil, op, init), do: init

### Binary Search Tree MIPS confusion

I have a project where I need to create a binary search tree in MIPS. I have it well understood in C but MIPS is where I get lost. My professor has included this code to work with the inserting method. I am confused on the difference between addNodeToTree and addNode: # add a node to tree # # input: \$a0 the address of the tree # \$a1 the value you want to add to the tree addNodeToTree : subu \$sp, \$sp, 4 # adjust the stack pointer sw \$ra, 0(\$sp) # save the re

### Binary How to edit .bin disc image files?

I want to edit bin disc image before burning to disc please help me. I tried using Winrar and 7zip but it didn't work.

### binary to NAND gate - boolean algebra

I am taking a digital logic class and i am trying to multiply this binary number. I am not sure what a carry in is and a carrry out. the teachers slides are horrbile. It appears he used a truth table to do this but its confusing. X1X0 + Y1Y0 ---- Z2Z1Z0 I think thats how its set up! Now, for the multiplication part 1 carry in? 110101 X 1101 ------ 101011001 thats what i ended up with. Probobly, not right! I think my truth table should look something like this: keep in mind

### Binary How can I represent a self-enumerating pangram as a boolean function?

The wiki article for self-enumerating pangrams states that they are computed using Binary Decision Diagrams. I've been reading about BDDs and from my understanding you need to represent some problem as a boolean function before you can construct a BDD for it. How would I go about doing this? I've been thinking about the problem for a few days now, and I'm pretty sure you could representing the input to the boolean function using a straightforward encoding: 10000 01010 01011 10101 ... 16A's 10

### Binary How to get reminder of XOR division in calc.exe?

I would like to understand how I can calculate manually CRC encoding. I have message to be sent like 1110 1101 1011 0111 and code generator 11001. In order to encode the message I add five zeros to the message (1110 1101 1011 0111 00000) and divide it by generator 11001. I should receive 1011000000100100 with reminder 0000100 - in such a case I can replace five zeros with right part of reminder (00100). This is what I can see in the example found somewhere. But I cannot calculate it with Wind

### Binary numbers in c program

I'm trying to write a program that prompts the user to enter a positive integer N and prints the set of all binary strings of length N. For example, if the user enters 3, the program prints: 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 I have been trying this for a while but I was unable to do it. If someone can help me with this I will appreciate it!! Thanks

### Binary Please can somebody help to explain this code

This is the code I was given; d = 0 binary = raw_input('Please enter a number between 0 - 11111111 in binary: ') for digit in binary: d = d*2 + int(digit) print d It's this part below which I really don't understand: for digit in binary: d = d*2 + int(digit) Any help is appretiated, thankyou

### Binary Algorithm for 2's complement division

Came across two division algorithms (restoring and non-restoring) applicable to signed magnitude numbers. But couldn't apply it for numbers in 2's complement format. Are there any algorithms for 2's complement division?

### Converting large decimal number into binary

I am tasked with finding the binary representation for the number 3.4219087*10^12. This is a very large number (and I have to do this by hand), so I was wondering if there was some sort of short cut or technique I could use to convert it instead.

### Binary What is wrong with my IEEE 754 floating point representation?

I am being asked in a homework to represent the decimal 0.1 in IEEE 754 representation. Here are the steps I made: However online converters, and this answer on stack exchange suggests otherwise. They put this solution: s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm 0 01111011 10011001100110011001101 The difference is the number 1 at the right. Why isn't it 1100, why is it 1101?

### How to count the number of binary 1's in MIPS code?

First, I started this work by typing up a C-code that counted the number of binary 1's in a positive number. I found it easier to type C-code first and then try to convert it. My C-code is as follows: #include <stdio.h> int main(void) { int num; int remainder; int one_count=0; int input_num; printf("Please enter a positive integer: "); scanf("%d",&num); input_num = num; while (num > 0) { remainder = num % 2; if(remainder == 1) { on

### Binary left and right shift

There are two questions made me feel confused. What is 1101011(2) in 8 bit binary left shifted by 5? What is 001010100(2) in 12 bit binary right shifted by 3?

### Binary Is there overflow or underflow?

Assume 185 and 122 are unsigned 8-bit decimal integers.Calculate 185 – 122. Is there overflow, underflow, or neither? overflow (floating- point) A situation in which a positive exponent becomes too large to fit in the exponent field. underflow (floating- point) A situation in which a negative exponent becomes too large to fit in the exponent field. So 185: 10111001 (binary) and 122 = 01111010 (binary) Where do I go form here? Is this subtraction right? 10111001 -01111010 00

### Full binary output

I'm receiving data from tcp socket in binary view. In erlang shell i see: <<18,0,0,0,53,9,116,101,115,116,32,103,97,109,101,1,0,0,1, 134,160,0,3,13,64,0,0,0,20,...>> How can i show all data without ... Thank you.

### Tensorflow target integer to binary classification

Is it possible to manipulate data loaded from tfrecords inside a Tensorflow graph? Details: I am trying to do a binary classification {1, 0} from an integer target label. Integer values are discrete in the the domain {0, 1, 2, 4, sys.maxsize}. What I want is to give me 1 if label is 4 or 0 otherwise. Is that possible without re-encoding the dataset? I am using sparse_softmax_cross_entropy_with_logits() to compute logits, which of course doesn't work with the above integer. / Thank you, F

1    2   3   4   5   6  ... 下一页 共 6 页