Total members 11890 |It is currently Fri Apr 19, 2024 3:01 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





[li[/list] Programmer:  


QUESTION # 1
Machine languages are the only languages understood by computers. While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers in the form of 0 and 1. Let us practice to manipulate these binary numbers understandable by the computers.
There should be class Decimalthat takestwo decimal numbers as an input from the user by creating an input () member function. The other member functions of classshould also include overloading the “+”, “*”,“++” and “--” operators in the natural way.
Another class Binary should be able to add and subtract two binary numbers using overloaded operators. Create friend functions that overload operators “+” and “*” in the natural way.
Binary subtraction is performed by 2’s complement methodology. For example;
• Align the two numbers as you would in decimal subtraction.
• Append leading zeros if necessary to represent both numbers with the same number of digits. For example, convert 101-11 to 101-011 so that both have three digits.
• Apply two's complement to the second term.
• For each digit in the number, change every 1 to 0 and every 0 to 1.
• Add 1 to the number.
• Add the complemented number to the first term. Now the original 101 - 11 has become 101 + 101 = 1010.
• The sum in the previous step should have one more digit than you started with. Remove the most significant digit from the sum to get 101 - 11 = 010. If you don't have an extra digit, you tried to subtract a larger number from a smaller one.

Binary numbers should be treated as string arrays for performing operations in an easier way. Keep track of length of the number. Decide the data members of both classes according to your understanding. Write data conversion routines in both classes to transform binary numbers into decimal ones and vice versa. In main () assign the objects of classes to each other to perform conversions. Include functions to display results of manipulation in both of the classes.

please make this program




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : operator overloading
 What is Operator Overloading? !!!     -  
 unary operator overloading     -  
 Operator overloading easy code     -  
 overloading << and >>     -  
 Function Overloading     -  
 Using the ? Operator     -  
 What is the % operator     -  
 operator int()     -  
 trinary operator     -  
 Sizeof Operator     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com