Permalink
Find file
93f26cf Jun 24, 2016
48 lines (35 sloc) 1.13 KB

3rd Bit

Description

Using bitwise operators, write a javascript function(that accepts a single array with arguments as a parameter) that uses an expression to find the value of the bit at index 3 of an unsigned integer read from the console.

  • The bits are counted from right to left, starting from bit 0.
  • The result of the expression should be either 1 or 0. Print it on the console.

Input

  • The only element of the parameter array, will be a positive integer as a string - the number whose 3rd bit you must print.

Output

  • Output a single number - 1 or 0 - the value of the 3rd bit, counted from 0 and from right to left.
  • You can use console.log to print the results or you can use return to return the answer. Both are correct.

Constraints

  • The input number will always be a valid positive integer number.
  • Time limit: 0.2s
  • Memory limit: 16MB

Sample tests

Sample test 1

Input

['15']

Output

1

Sample test 2

Input

['1024']

Output

0

Submission

  • Submit your code here