-5

What does this function do ?

inline bool myFunc(int aVal) {return aVal & 1;}

Edit I have edited the code to be runnable.

UCf
  • 29
  • 1
  • 5

1 Answers1

2

Keyword inline shall be written with lower case letters.

inline bool myFunc(int aVal) {return aVal & 1;}

The function returns true if the first bit of the value aVal is set to 1. Otherwise it returns false.

Using this function you can check for example whether aVal is odd or even number. :) If the function will return true then it means that the number is odd.

The operator & is bitwise AND operator.

yizzlez
  • 8,757
  • 4
  • 29
  • 44
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335