Jump to content
  • Advertisement
Sign in to follow this  
l jsym l

Question using Log

This topic is 2700 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I was just wondering if there was a possible log function or any function, or way, that I could do this.

I want to get three separate integers:
int a = 0x1;
int b = 0x0;
int c = 0x0d;

However, I want to put these integers so the new integer intact is 0x100d.

I understand if I have 100d and just do

int num1 = (intTemp / 0x10000);
int rem1 = (intTemp % 0x10000);
int num2 = ( rem1 / 0x1000 );
int rem2 = ( rem1 % 0x1000 );
int num3 = rem2;

It will split it up reverse of how I want it done now. Is there a way to reverse what I did here^^ ?

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
you can use logic operations to do that.
& - logical and
| - logical or
<< bit shift left
>> bit shift right

For instance:
0x1 | (0x1 << 1) => 0x11
(0x20 & (0xF0) ) >> 8 => 0x2

Share this post


Link to post
Share on other sites

For instance:
0x1 | (0x1 << 1) => 0x11
(0x20 & (0xF0) ) >> 8 => 0x2
Yeah shifting and or'ing is the answer, except you're example's a little bit off ;)
0x1 | (0x1 << 1) => 0x3
(0x20 & (0xF0) ) >> 8 => 0x0

0x1 | (0x1 << 4) => 0x11
(0x20 & (0xF0) ) >> 4 => 0x2

Share this post


Link to post
Share on other sites

[quote name='KulSeran' timestamp='1303872992' post='4803360']
For instance:
0x1 | (0x1 << 1) => 0x11
(0x20 & (0xF0) ) >> 8 => 0x2
Yeah shifting and or'ing is the answer, except you're example's a little bit off ;)
0x1 | (0x1 << 1) => 0x3
(0x20 & (0xF0) ) >> 8 => 0x0

0x1 | (0x1 << 4) => 0x11
(0x20 & (0xF0) ) >> 4 => 0x2
[/quote]
ah...... derp. thanks hodman. obviously i was only half thinking when i wrote that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!