Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help writing these functions for the code below C++ bool isBIN8(string &) This function checks that the binary number considered is between 1 and 8

Help writing these functions for the code below C++

  • bool isBIN8(string &)

    This function checks that the binary number considered is between 1 and 8 characters long and that each character is either 0 or 1. If either check fails, the function returns false. Otherwise, true.

  • string bin2str(byte)

    This function does the reverse of the str2bin function. That is, given an unsigned char, it computes and returns the corresponding ASCII string. Use bitwise operations to determine when and how to set a bit.

  • bool isVALID(string &)

    This function implements a Boolean expression for checking that the operation is a single character which is either a '+' or a '-'. If not, the function return false. Otherwise, true.

#include #include #include using namespace std;

typedef unsigned char byte;

byte msb(byte); bool overflow(byte, byte, byte); byte twoscomplement(byte);

byte str2bin(string &); string bin2str(byte); string bin2dec(byte);

bool isBIN8(string &); bool isVALID(string &);

int main(int argc, char *argv[]) { string sX, sY; string op;

cout << "X> "; cin >> sX; if (cin.eof()) return 1;

if (!isBIN8(sX)) { cout << "error: not 8-bit binary number "; return 1; }

cout << "Y> "; cin >> sY; if (cin.eof()) return 1;

if (!isBIN8(sY)) { cout << "error: not 8-bit binary number "; return 1; }

cout << "op> "; cin >> op; if (cin.eof())

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_2

Step: 3

blur-text-image_3

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions