- In This Activity You Will Continue Implementing The Base10tobase2 Function This Function Will Receive Negative Positi 1 (45.35 KiB) Viewed 64 times
In this activity, you will continue implementing the Base10toBase2 function. This function will receive negative, positi
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
In this activity, you will continue implementing the Base10toBase2 function. This function will receive negative, positi
In this activity, you will continue implementing the Base10toBase2 function. This function will receive negative, positive, and zero integer values as input, convert that value to a 8-bit base-2 value encoded as an std::string, and return the string to the caller. If your output exceeds the bounds for an 8-bit integer, you should throw an invalid argument error (i.e., std::invalid argument). When converting a negative base-10 value to binary, encode the binary representation using two's complement. Make sure that your string begins with "Ob" directly, followed by the binary encoding of the decimal value (with as many leading zeros as needed to reach 8-bits). For example, invoking Base 10toBase 2 (-8) would return "0b11111000". Hint: What is the range of values for our representation? 1 #include "converter.hpp" 2 3- std::string Base10toBase2 (int base10_value) { 4 5 6} 7 //Your code here! return str; base10tobase2-pt2 driver.cc converter.cc converter.hpp CS 128 A+ Editor