| | |
ALU simulator
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 20
Reputation:
Solved Threads: 0
hi, i am trying to write a simulation for a very simple ALU and am having trouble with the AND/OR operations. I want to AND/OR integers bit wise with the two integers being passed to a function in hex form and the result returned in hex form so :
int ANDoperation(0x0011, 0x0101)
would return: 0x0001.
iv tried to turn the int's into strings, compare them, then convert the result to int and return that but was having problems with that.
any help is appreciated
int ANDoperation(0x0011, 0x0101)
would return: 0x0001.
iv tried to turn the int's into strings, compare them, then convert the result to int and return that but was having problems with that.
any help is appreciated
Make a function that takes 2 integers as parameters, and returns an integer.
You can print the result in hexadecimal form with the std::hex mode:
You can print the result in hexadecimal form with the std::hex mode:
C++ Syntax (Toggle Plain Text)
num = ANDoperation(0x0011, 0x0101); std::cout << "0x" << std::hex << num;
Last edited by John A; Apr 12th, 2009 at 1:09 am. Reason: changed my solution to C++ :o
"Technological progress is like an axe in the hands of a pathological criminal."
All my posts may be freely redistributed under the terms of the MIT license.
All my posts may be freely redistributed under the terms of the MIT license.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Weird strtok() problem
- Next Thread: MSXML4 with c++
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






