Do the exercises in the For the More Curious – Bit Manipulation section.  Write a short paper (around 500 words) describing how the functions here might be useful, and proposing ways that you might utilize this functionality within a real program.  Submit your paper here.


For the More Curious: Bit Manipulation
Earlier, you saw that numbers have a binary representation. You can get the binary representation for a number at any time. For example, you could ask for the binary representation of the integer 42 with:
    42.toString(radix = 2)
    “101010”
(The radix parameter indicates the desired base of the outputted number. By specifying 2, you request a number in base 2, or binary. The default radix is 10, which outputs a decimal number. Another commonly used radix is 16, which returns a hexadecimal string.)
Kotlin includes functions for performing operations on the binary representation of a value, called bitwise operations including operations you may be familiar with from other languages, such as Java, C, and JavaScript. Table 5.3 shows commonly used binary operations in Kotlin.
Table 5.3  Binary operations
FunctionDescriptionExample
shl(bitcount)Shifts bits left by bitcount.
42.shl(2)
10101000
shr(bitcount)Shifts bits right by bitcount.
42.shr(2)
1010
inv()Inverts bits.
42.inv()
11111111111111111111111111010101
xor(number)
Compares two binary representations and performs a logical exclusive or operation on the corresponding bit positions, returning 1 for each bit position that has a 1 in one input but not[]


What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but you proved you are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 11***| Rating: ⭐⭐⭐⭐⭐
"This company is the best there is. They saved me so many times, I cannot even keep count. Now I recommend it to all my friends, and none of them have complained about it. The writers here are excellent."


"Order a custom Paper on Similar Assignment at essayfount.com! No Plagiarism! Enjoy 20% Discount!"