Questions tagged [bit]

A bit is a single binary digit.

A bit refers to a single binary digit, the smallest possible amount of information. In print is usually represented as either 0 or 1, with many different representations in technology, like the presence or absence of an electric current or magnetic field.

Eight bits form a single , although historically the term has been used for other sizes as well.

3593 questions
1
vote
0 answers

Reading BitMap header Information and Printing It

I have 2 c files and 1 header file. I am trying to read any bmp file and print out its information. But I keep getting very large numbers for each of the field variables and I do not know why. Any help would be appreciated thanks. BMPread.c #include…
Master Maq
  • 11
  • 4
1
vote
2 answers

How can I mask bits?

I have a byte, whose value in binary is 11111111. I have to extend my byte to 16 bits 0101010101010101 according to these rules: if bit = 1, now is 01. If bit = 0, now is 10. For example: 00001111 -> 1010101001010101 00000101 ->…
joao brum
  • 31
  • 1
1
vote
2 answers

Signed and Unsigned bits

What is the difference between signed 8-bits 1's and 2's complements and unsigned 8-bits? Does it have to do with adding 1 after the number all the way to the left? I'm lost lol
user7239323
1
vote
1 answer

signed integer, arithmetic shift to the left

I'm trying to understand how "signed integer" and "arithmetic left shift" works in swift and iOS. In the book, swift programming language 3.0, it says I tried it out with the following code: I understand with signed integer, binary…
Thor
  • 9,638
  • 15
  • 62
  • 137
1
vote
1 answer

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…
samstr
  • 190
  • 2
  • 7
1
vote
1 answer

Inversion of a bit

I haven't been able to find a common-lisp function (or macro) that simply inverts a bit. There are functions that operate on bit arrays, and logical functions that operate on numbers, but these would seem to involve extra steps for inversion of a…
davypough
  • 1,847
  • 11
  • 21
1
vote
1 answer

cpu power consumption and set bits

I'm working on side channel attack on prime number generation by measuring power consumed by the cpu while doing that, let's say that the cpu process 10000 mpz_t integer ( size 512 ) does the number of set bits (Hamming weight) in those integers…
Hamza Tahiri
  • 488
  • 3
  • 13
1
vote
1 answer

How do I change the bytes of a 32-bit integer?

I'm trying to add two binary numbers together using only logical statements and binary arithmetic operators. But I'm confused on how to actually change the bits. It is mostly the out variable that I am trying to change, but it keeps getting zeroed…
1
vote
0 answers

Reduce memory footprint of data.table with lots of logical variables

I have a large data.table that is getting pretty large (>1TB) and starting not to fit my server's RAM (~1TB of RAM). The file has person and family identifiers and a large number of logical indicator variables (~120). The data is used to generate…
LucasMation
  • 2,408
  • 2
  • 22
  • 45
1
vote
2 answers

Efficient single-bit negation in Fortran

I'm writing performance-intensive Fortran code, which has at its core a matrix-free matrix multiplication subroutine mfmult(x,y), which takes an input vector x, and returns an output vector y such that if i = i_{n-1}i_{n-2}...i_2i_1i_0 is an n-bit…
Paradox
  • 1,935
  • 1
  • 18
  • 31
1
vote
1 answer

bitwise operators and shifts issues in c

Hello I am having some trouble with the bitwise operators and shifts. I believe check_flag() is working however set_flag() is not. Could someone explain what's wrong with it? #include void set_flag(int* flag_holder, int…
John
  • 49
  • 7
1
vote
2 answers

Will an Infinite Loop ever end by Itself

Let's assume we have the following loop: for (int i = 1; i < 2; i--) { cout << i << endl; } Without a doubt, this is an infinite for-loop. However, my question is that for how long will it run? Because my prof said that given…
BusyProgrammer
  • 2,783
  • 5
  • 18
  • 31
1
vote
1 answer

what is the zero connected to some MUX in this 8 bit right shifter

in this picture of an 8 bit right shifter, can someone please tell me what those 0's represent ? in the first row of MUX there is one zero connect, in the second row the first two have 0 connected, and in the third row there are 4 zeros connected?
GarudaAiacos
  • 161
  • 2
  • 17
1
vote
0 answers

MCS-51 code to fit custom LCD hardware

I made myself a character LCD driver (LCD has an HD47780 chipset) in hardware where data is predefined on a ROM, and I also made a circuit to load the ROM. In the first image below, part of the Rom maker circuit (which I hook up to my computer…
Mike -- No longer here
  • 2,064
  • 1
  • 15
  • 37
1
vote
3 answers

Exercise 6 from Chapter 11 Programming in C Kochan, finding bit patterns

hoping for some help with bitwise operators. The exercise reads as following: Write a function called bitpat_search() that looks for the occurence of a specified pattern of bits inside an unsigned int. The function should take three arguments, and…
CHV
  • 21
  • 2