Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A bitwise AND takes two equal-length binary representations and performs the log

ID: 3574322 • Letter: A

Question

A bitwise AND takes two equal-length binary representations and performs the logical AND operation on each pair of the corresponding bits. Thus, if both bits in the compared position are 1, the bit in the resulting binary representation is 1. Otherwise, the result is 0. For example the bitwise AND of 10110 and 10011 is 10010. Write an SML function bitwise_and that takes two integers as parameters and returns the 8-bit bitwise AND of the two integers' binary representations as a list of 1s and 0s. You may assume that both parameters are in the range 0 through 255, inclusive. Examples: bitwise_and(31, 12) would return [0,0,0,0,1,1,0,0] bitwise_and(45, 172) would return [0,0,1,0,1,1,0,0] bitwise_and(65, 255) would return [0,1,0,0,0,0,0,1]

Explanation / Answer

fun convertDecimalToBinary(num : int) = if num
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote