Can i convert from Integer to decimal via GE?

Talk about making games.

Can i convert from Integer to decimal via GE?

Postby bat78 » Fri Apr 12, 2013 5:49 pm

Hello guys, i just would like to test "what happen to the decimal/binary" when i use different operators, such as ~ >> << && || ..on the specific value that i need to convert to the decimal. If there is no such way because i actually don't know and if someone can convert me 10 (1010) with 20 bits on right, i will give points and be grateful :)
(IF someone can provide me a photo table / explanation for that conversation i will really appreciate it also)

I think it is like:
01010000000000000000

OR

00000000000000000101

But i am completely not sure :D And we talk about logical shifting, i mean not arithmetic.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Can i convert from Integer to decimal via GE?

Postby skydereign » Fri Apr 12, 2013 8:55 pm

Is there something specific you want to do? Or just to know what the bitwise operators do? You might want to take a look at this. http://www.thegeekstuff.com/2012/10/bitwise-operators/
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Can i convert from Integer to decimal via GE?

Postby bat78 » Fri Apr 12, 2013 10:25 pm

Nononono, i know anything else, i learned the whole C++ operators, i just want to know if we want to shift the bits of 10 by 20 at right, how should be the binary/decimal value.
Code: Select all
10 >> 20 //means we shift 10's binary with 20 bits by right. I know 10 is with binary code [b]1010[/b]


I know anything about the operators guys,
>> - move my right / instream
<< - move by left / outstream
10~=20 - // ~ means NOT at bitwase and 10 ~= 20 is like invertying the bites. e.g 00110001 will be 11001110
| will return one - true in case they both are 1
& will return one - 0 -false in case, both are both 0
^ with stands for XOR (Xpressive OR) Will make the bites like it will return 1 - ture if both are different or else 0 false

ik that. i just need shifting schemogram
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Can i convert from Integer to decimal via GE?

Postby skydereign » Sat Apr 13, 2013 1:12 am

Well if you know how the operators work, it should be clear if you shift 10 like that, the binary representation would be entirely 0. Shift left/shift right just shift the bits, adding 0s to the front or the back.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Can i convert from Integer to decimal via GE?

Postby bat78 » Sat Apr 13, 2013 1:33 pm

It is not clear at all.. however i had enough time to learn it from sources this two days. Jut had to know how the shift exactly works.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Can i convert from Integer to decimal via GE?

Postby GEuser » Thu Apr 18, 2013 8:31 pm

bat78 wrote:It is not clear at all.. however i had enough time to learn it from sources this two days. Jut had to know how the shift exactly works.


I know what you mean. It was confusing to me too at first. In the above you would get 0 because once all the 1010 bits have been moved over the 0's that replaced 1010 (as you shift over) are the ones that get shifted too eventually when you run out of your orginal value.

When I was first using them I was confused about whether it alters what you've shifted e.g.

B = A >> 10;


I wrongly thought that it might change the A then store result in B but no, the A >> 10 parts gets stored somewhere else (microprocessor's accumulator in ALU or one of processor's registers???) and then transfered to B, so the A is safe, it is not changed. I also found using unsigned int was safer if you using them as some sort of status register flags or similar. because the last bit in int (bit 32) is used to signify negative values and creates wrong result used up in your shift.
GEuser
 
Posts: 204
Joined: Thu Jan 05, 2012 3:08 pm
Score: 19 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest