• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Hex to unsigned long?

Jumpem

Lifer
I have a simulation project I am doing.

One of the functions takes an unsigned long. I am given 2^15 or 00007FFF for it to be. How do I get that hex value into long?
 
converting hex value into long makes absolutely no sense.

edit: can you rephrase the question? you are comparing apples to oranges with that question.
 
Originally posted by: shuan24
converting hex value into long makes absolutely no sense.

edit: can you rephrase the question? you are comparing apples to oranges with that question.


The professor gave us the maximum memory size for our simulator as 00007FFF. But the library function that implements memory takes a long.
 
Do you really mean an ASCII string of hex characters?

>> Nevermind, I'm a complete idiot. It's just 2^15 = 32,768.

In most languages no such conversion is needed unless it's ASCII.

unsigned long foo = 0x07fff ; // C++
 
Originally posted by: DaveSimmons
Do you really mean an ASCII string of hex characters?

No this number is a constant that gets used at start up when creating the simulated "memory".
 
Originally posted by: Jumpem
Originally posted by: shuan24
converting hex value into long makes absolutely no sense.

edit: can you rephrase the question? you are comparing apples to oranges with that question.


The professor gave us the maximum memory size for our simulator as 00007FFF. But the library function that implements memory takes a long.


even so, i don't see what the problem is. The max memory is 32KB. Your function takes a long....not any different from taking a unsigned int.
 
Originally posted by: shuan24
i guess you meant hex to decimal? or hex to binary?


Hex to decimal. It was simple, I just wasn't looking at it right.

He gave us the hex value to use on paper. But the code needed the decimal value.
 
Originally posted by: shuan24
i guess for a comp arch class? good luck to you sir!

Yeah, it's comp arch. It's really kicking my butt. I transfered here from another school, and got transfer credit for the prereq course. Needless to say I'm not quite prepared for what I've gotten myself into.
 
Back
Top