Question: NEED MATLAB CODE Base-2 numeral systems are the basis for binary numbers used in computers and other devices. Write a function baseTwo with one input,

NEED MATLAB CODENEED MATLAB CODE Base-2 numeral systems are the basis for binary numbers

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 (2n where n is a positive integer) that is smaller than or equal to the inputted integer.

128 64 32 16 8 4 2. 1 27 26 25 24 23 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 (2n 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=baseTwo (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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!