bitwise operations

PPTX 28 стр. 474,7 КБ Бесплатная загрузка

Предварительный просмотр (5 стр.)

Прокрутите вниз 👇
1 / 28
bitwise operations bitwise operations algorithms and data structures course numbers representation numbers in computer represented in binary numeral system. every decimal number you see at output or give to program by yourself converted to binary. there are number of various binary representations for signed numbers. algorithms and data structures course numbers representation 3 basic types of numbers representation in computer: sign and magnitude method. ones' complement. two's complement. algorithms and data structures course numbers representation sign and magnitude method simple representation with power of 2s for both signed and unsigned numbers․ first bit are used for sign, 0 for positive numbers, 1 for negative: 13 = 0001 11012 -13 = 1001 11012 91 = 0101 10112 -91 = 1101 10112 algorithms and data structures course numbers representation sign and magnitude method advantages: easy to calculate signed and unsigned numbers representation. disadvantages: there are two zeroes in this representation: 010 = …
2 / 28
res course numbers representation two's complement positive numbers are the same simple, negative values are the bit complement of the corresponding positive value, the value of 1 is then added to the resulting value, ignoring the overflow which occurs when taking the two's complement of 0: 1310 = 0001 11012 -1310 = 1110 00112 9110 = 0101 10112 -9110 = 1010 01012 010 = -010 = 0000 00002 algorithms and data structures course numbers representation two's complement advantages: easy to perform standard arithmetic operations with signed and unsigned numbers 1210 + 2310 = 0000 11002 + 0001 01112 = = 0010 00112 = 3510 1210 - 2310 = 0000 11002 + 1110 10012 = = 1111 01012 = - 0000 10112 = -1110 there is only one zero in this representation: 010 = -010 = 0000 00002 so the range of numbers this method allows to represent is modern computers …
3 / 28
10 = 0010 01012 >> 410 = 0000 00102 = 210 algorithms and data structures course bitwise operations manipulations i-th power of 2: 1 << i change i-th bit of number n to 1: n = n | (1 << i); change i-th bit of number n to 0: n = n & ~(1 << i); toggle i-th bit of number n: n = n ^ (1 << i); check if i-th bit is 1: if(n & (1 << i) != 0) algorithms and data structures course bitwise operations problem: single number you are given an array of integers. every element appears twice, except for one. you need to find the element that appears only one time. your solution should have a linear runtime complexity (o(n)). try to implement it without using extra memory. examples: algorithms and data structures course input output 5 3 5 2 2 3 5 7 …
4 / 28
bitwise operations - Page 4
5 / 28
bitwise operations - Page 5

Хотите читать дальше?

Скачайте все 28 страниц бесплатно через Telegram.

Скачать полный файл

О "bitwise operations"

bitwise operations bitwise operations algorithms and data structures course numbers representation numbers in computer represented in binary numeral system. every decimal number you see at output or give to program by yourself converted to binary. there are number of various binary representations for signed numbers. algorithms and data structures course numbers representation 3 basic types of numbers representation in computer: sign and magnitude method. ones' complement. two's complement. algorithms and data structures course numbers representation sign and magnitude method simple representation with power of 2s for both signed and unsigned numbers․ first bit are used for sign, 0 for positive numbers, 1 for negative: 13 = 0001 11012 -13 = 1001 11012 91 = 0101 10112 -91 = 1101 10112 …

Этот файл содержит 28 стр. в формате PPTX (474,7 КБ). Чтобы скачать "bitwise operations", нажмите кнопку Telegram слева.

Теги: bitwise operations PPTX 28 стр. Бесплатная загрузка Telegram