Jump to content
• Advertisement

Public Group

# Question using Log

This topic is 2789 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

##### 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

##### Share on other sites
Alright thanks! I'll see if I can figure it out from that

#### Share this 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

##### 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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5
khawk
14
• Advertisement

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633741
• Total Posts
3013624
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!