Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 984 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 2 of 3 1 2 3
Re: Tutorial: bitwise"&" operator use, **very usef [Re: fastlane69] #18994
11/28/03 13:37
11/28/03 13:37
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline OP
Expert
Rhuarc  Offline OP
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
I'm using it for my inventory system as well. I have a (simulated) 2d array containting all my details for each inventory item, and set flags within that. I then store handles in another array for containers to keep track of where my inventory items are.


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: Tutorial: bitwise"&" operator use, **very usef [Re: Rhuarc] #18995
12/01/03 11:58
12/01/03 11:58
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
1) Since 3DGS vars have 3 decimal places, this is 6 bits and theoretcally, 6 more items. How, if at all, could we use the bitwise commands to take advantage of decimals places?

2) Along the same vein, the sign of a var would be an extra bit. Could I do the following check:

if(bit_info&-1)
{
do_something();
}

if(bit_info&1)
{
do_something_else();
}



Re: Tutorial: bitwise"&" operator use, **very usef [Re: fastlane69] #18996
12/01/03 17:30
12/01/03 17:30
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
answered my second question: it seems that bitwise operations aren't sensative to the +/- sign.

I suspect this means they aren't wise to the decimals.

Re: Tutorial: bitwise"&" operator use, **very usef [Re: fastlane69] #18997
12/02/03 08:30
12/02/03 08:30
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
I haven't tried, but normally it's open to interpretation, whether a number is positive or not.

A5 uses a fixpoint format, I think it was 22.10

This means we have a size of 4 byte, this is 32 bits.
The last 10 (1024 combinations, makes 3 decimal places) bits are taken for the positions after the decimal point, the remaining 22 bits are used for the positions before the decimal point.
With this format, we can store numbers, but there is no informations about the sign yet.
To get negatvie and positive numbers, the highest bit is used. A 1 means negatvie number, a 0 means negative number.

You might think we lose a lot of place with this as we only have 21 (2097152 combinations) instead of 22 (4194304) bits. That is not true. In fact we only moved the area where we can store numbers. We can't use that high positive nubmers anymore, therefore we can store negative numbers. It's all a question of interpretation.

(The fixpoint format of A5/6 might differ from 22.10, I don't know it out of my mind right now. The idea behind it is the same, it only changes the maximum number sizes/precision before and behind the decimal point. Maybe Conitec also uses some of the leading bits as variable flags like the info flag, I guess you will have to ask Conitec about that for more details)

Re: Tutorial: bitwise"&" operator use, **very usef [Re: FBL] #18998
12/02/03 15:13
12/02/03 15:13
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Thanks for the clarification Firo.

So far, I can use the +/- info by doing two checks: first if my value is > or < 0 (ie plus or minus), and then I do a bit check. In my application, this is the way I control whetehr an item is being put on or off: if the bit is +, then that item is added; if -, then subtracted.

So far, It seems I can't do a direct bitwise check for -1. I'll experiement a little with the bits and see what kind of control I can wrangle out of them. Want to see if I can use the decimal places in the same way as the main places.

Re: Tutorial: bitwise"&" operator use, **very usef [Re: fastlane69] #18999
12/02/03 21:38
12/02/03 21:38
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Sorry I made a mistake above. most significant bit=0 means positive number, of course.

Re: Tutorial: bitwise"&" operator use, **very useful** [Re: Rhuarc] #19000
12/19/03 03:43
12/19/03 03:43
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Give that man a round of applause....
The implications of this if used properly is huge.... I gave you 5 stars and I would have given more. THIS IS the most informative post @ this forum I have read!

It has so many uses, and the bandwidth saved? well it could make multiplay very effecient....

Thanks for making the obvious so clear.


The Art of Conversation is dead : Discuss
Re: Tutorial: bitwise"&" operator use, **very useful** [Re: indiGLOW] #19001
12/23/03 02:04
12/23/03 02:04
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline OP
Expert
Rhuarc  Offline OP
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Hehe, thanks man.
I actually am looking at ways to compress the number (might have to go to a dll) into a smaller variable type for multiplayer use. Also, there are methods to store *multiple* strings of flags within it by adding other non-square numbers, but I'm still trying to sort that one out in my head. Thats when you get into prime numbers and such. (eyes start rolling in different directions....) I hope I'm on the right track .

-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: Tutorial: bitwise"&" operator use, **very usef [Re: Rhuarc] #19002
12/17/05 17:35
12/17/05 17:35
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Wow, almost 2 years ago I read this post! Here I am all that time later returning to it. Fantastic!

Everyone should read this, at least twice! lol


The Art of Conversation is dead : Discuss
Re: Tutorial: bitwise"&" operator use, **very usef [Re: indiGLOW] #19003
12/19/05 02:52
12/19/05 02:52
Joined: Jul 2002
Posts: 2,813
U.S.
Nadester Offline

Expert
Nadester  Offline

Expert

Joined: Jul 2002
Posts: 2,813
U.S.
I'd yell at you for reviving an old topic, but I'm not going to because this is a very important subject

But so much more could be said about bitwise operations. A better way to set and turn off specific bits than what rhuarc said is like below:

// maybe give these names for when you set skill flags
#define bit0, 0x1;
#define bit1, 0x2;
#define bit2, 0x4;
#define bit3, 0x8;
#define bit4, 0x10;
#define bit5, 0x20;
#define bit6, 0x40;
#define bit7, 0x80;

var flags;

// turn a bit on...
function turnbiton()
{
flags|=BIT0;
flags|=(BIT1|BIT2|BIT3|BIT4);
}

// turn bit off
function turnbiton()
{
flags&=^BIT5;
flags&=^(BIT1|BIT2|BIT3|BIT4);
}


--Eric
Page 2 of 3 1 2 3

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1