Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

128 64 32 16 8 4 2 1 27 26 25 24 22 22 21 2 Base-2 numeral systems are the basis for binary numbers

image text in transcribed

128 64 32 16 8 4 2 1 27 26 25 24 22 22 21 2 Base-2 numeral systems are the basis for binary numbers used in computers and other devices. Write a function baseTwo with one input, a positive integer. The output should be the highest power of 2 (21 where n is a positive integer) that is smaller than or equal to the inputted integer. Test case 1 result=baseTwo (16) result=16 $ 2^2=4, 2^3 = 8, 2*4=16 16 is the highest power of 2 less than or equal to the inputted number Test case 2 result=base Two (2047) result=1024 $ 2*10=1024, 2*11=2048 1024 is the highest power of 2 less than or equal to the inputted number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions