How to resolve the algorithm Bitwise operations step by step in the Scheme programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Bitwise operations step by step in the Scheme programming language

Table of Contents

Problem Statement

Write a routine to perform a bitwise AND, OR, and XOR on two integers, a bitwise NOT on the first integer, a left shift, right shift, right arithmetic shift, left rotate, and right rotate. All shifts and rotates should be done on the first integer with a shift/rotate amount of the second integer. If any operation is not available in your language, note it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Bitwise operations step by step in the Scheme programming language

Source code in the scheme programming language

(import (rnrs arithmetic bitwise (6)))

(define (bitwise a b)
  (display (bitwise-and a b))
  (newline)
  (display (bitwise-ior a b))
  (newline)
  (display (bitwise-xor a b))
  (newline)
  (display (bitwise-not a))
  (newline)
  (display (bitwise-arithmetic-shift-right a b))
  (newline))

(bitwise 255 5)

5
255
250
-256
7

  

You may also check:How to resolve the algorithm Cheryl's birthday step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Pierpont primes step by step in the REXX programming language
You may also check:How to resolve the algorithm Modular inverse step by step in the Oforth programming language
You may also check:How to resolve the algorithm Test integerness step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Tokenize a string with escaping step by step in the Sidef programming language