Questions tagged [binary]

Binary, the base-2 numeral system, represents numbers using two symbols: 0 and 1. For compiled computer programs, use the "executable" tag instead.

Binary is the base-2 positional numeral system. It represents numbers using two symbols: 0 and 1.

Computers use binary in digital circuitry using logic gates, where the symbols translate to states of off (0) and on (1).

Here are binary numbers corresponding to 0 to 10 in the decimal system:

Decimal   Binary
-------   ------
      0        0
      1        1
      2       10
      3       11
      4      100
      5      101
      6      110
      7      111
      8     1000
      9     1001
     10     1010

Other tags

14710 questions
4
votes
2 answers

Convert binary string to integer in php

In php how do I convert a string "1010101010" into the integer value represented by this binary number? eg "10" would go to 2, "101" would go to 5
wheresrhys
  • 22,558
  • 19
  • 94
  • 162
4
votes
6 answers

Check if the input number is in a valid binary format

i tried to make a simple program,which check if the input number from the user is a binary number and that number is in correct binary format -> without leading zeros. That below is my code,but it doesn't work. I would appreciate if someone could…
DeanTwit
  • 325
  • 4
  • 8
4
votes
1 answer

Use application loader to upload Mac OS X binaries to itunesconnect?

I added a new application for the new Mac OS X app store and the status is "waiting for upload", but when I launch the application loader it tells me "No eligible applications were found". I have ensured I am using the correct itunesconnect login by…
offthat
  • 400
  • 2
  • 10
4
votes
1 answer

Replace multiple characters in String with multiple different characters

I am working on a code that will convert binary digits to its corresponding value in words. For example, I would input "3" and the code will convert the number to "11", which is the binary representation of "3". The code will proceed to convert that…
Glace
  • 127
  • 1
  • 3
  • 10
4
votes
2 answers

Integer to BinaryString removes leading zero in Java

I wanted to convert an integer to binary string. I opted to use the native function that java allows Integer.toBinaryString(n). But unfortunately, this trims the leading zero from my output. Lets say for example, I give the input as 18, it gives me…
JackSlayer94
  • 805
  • 3
  • 16
  • 38
4
votes
3 answers

Converting binary lists to values required for combinations based on index of list

I generated a list of binary numbers in python with itertools, of which I want to convert all the 1 to 'ALL' and all the 0 to correspond to the index of the attribs list, where the attribs list is [1, 2], with the measure value 10 appended at the…
iteong
  • 715
  • 3
  • 10
  • 26
4
votes
1 answer

Why is the python "dtype=float" 8-byte rather than 4-byte?

These days, I've switched from Matlab to NumPy/SciPy. Today, I encountered a weird problem when I tried to load data stored in "binary format". Audio data is stored in the 4-byte single-precision floating point number format. I tried the following…
chanwcom
  • 4,420
  • 8
  • 37
  • 49
4
votes
2 answers

How do I create a PDF file from a binary code using Python?

I am trying to send myself PDF files per E-mail with Python. I am able to send myself the binary code of a PDF file, but I am not able to reconstruct the PDF file from this binary code. Here is how I obtain the binary code of a PDF file: file =…
Ron Lauterbach
  • 107
  • 1
  • 1
  • 12
4
votes
4 answers

How to get 2's complement of a binary number in Java programmatically

How to calculate the 2's Complement of a Hex number in Android/Java. For Example : String x = 10011010; 1's complement of x = 01100101; 2's complement is 01100110; How I can pro-grammatically achieve in Java? I had tried the…
Sarbjit Singh
  • 197
  • 1
  • 3
  • 13
4
votes
2 answers

Crystal lang how to get binary file from http

In Ruby: require 'open-uri' download = open('http://example.com/download.pdf') IO.copy_stream(download, '~/my_file.pdf') How to do the same in Crystal?
SeventhSon
  • 71
  • 5
4
votes
1 answer

Getting pairwise proportions of concordance in a binary dataframe

I have a dataframe with binary values like so: df<-data.frame(a=rep(c(1,0),9),b=rep(c(0,1,0),6),c=rep(c(0,1),9)) Purpose is to first obtain all pairwise combinations : combos <- function(df, n) { unlist(lapply(n, function(x) combn(df, x,…
thisisrg
  • 596
  • 3
  • 12
4
votes
6 answers

How to sort binary array in linear time?

http://www.techiedelight.com/sort-binary-array-linear-time/ Linear time means that we have to traverse the array only one time but according to the solution here, we will first traverse the array to find the number of zeros, and then we traverse it…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
4
votes
1 answer

Brainfuck with 1bit memory cells?

Would an implementation of the programming language Brainfuck, still be turing complete if its memory cells were 1bit in capacity, instead of the usual 8bit? The + and - instructions become identical, however this need not be a problem. I see no…
alan2here
  • 3,223
  • 6
  • 37
  • 62
4
votes
0 answers

How to intersect two binary images using MATLAB?

I would like to do the following: apply the sobel gradient to a binary image apply the laplacian gradient to the the same binary image intersect those two images in order to remove noise generated by the laplacian gradient output image .... I…
4
votes
3 answers

storing charcter and binary number in a hash map

I am trying to store a mapping of letters to a Binary number. Here is my Mapping ("h",001) ("i", 010) ("k",011) ("l",100) ("r", 101) ("s",110) ("t",111) For this purpose, I have created a hash map and stored the key value pairs. I now want to…