Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Problem with bit usage

Problem with bit usage

A PocketC native palm library offering native forms and assorted utilities

Postby antix on Tue Nov 08, 2005 9:45 pm

Problem im having is probaly answered somewhere in this forum or in the PToolbox docs but I have no idea how the bits are calculated. Does anyone know what im getting at? I looked at the examples and did some calculations to see if there is something like adding you have to do to get the final number but i got nothing exact. can <font size="6">ANYONE</font id="size6"> give me a link to the process or tell me? i would appreciate it if someone helped me here. thanks.

Image
Image
antix
 
Posts: 17
Joined: Tue Nov 08, 2005 9:37 pm
Location: USA

Postby jstadolnik on Tue Nov 08, 2005 9:54 pm

Can you elaborate on your problem? I have no idea what you are asking.

-Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby VengantMjolnir on Mon Nov 28, 2005 3:00 am

I think I understand what is being asked and I have a similar question. I understand the basics(I think) or hex... but I don't understand how to apply the bit codes that are in the examples. For instance, in the /sketch.c example included in the ptoolboxlib documentation there are two statements settting the mode variable to different values.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">while((e=event(1)) != 1) {
If(e==2) mode=0x03050000;
//round brush: width=5, radius=3
else mode =0x03050001;
plot(mode,penx(),peny(),0,0);
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
now, I do not understand exactly what portion of this is used to set the different modes. In every case of the functions I have used with single bit modes(ie 1, 2, 3, 4...) I could set it easily... but I really don't get the hex bit assignation method. Any help on this would be appreciated.
(to be specific I am trying to figure out how to set the brush width and radius)
also, if I wanted to use this function(plot) to connect the two points(current point and previous point) do I not set bit 1 to, well 1? In this case would I not use mode=0x13050000? I thought so but it doesn't work when I try it.(drag the pen fast and you get blips.. single plotted points)
I know I could make it work with a switch statement using e=fevent(1) and case 4: for pen move, then use Line() instead but that seems like a lot of wasted code if plot does it better.

"Fourth floor- toys, guns, keys to super weapons."
"Fourth floor- toys, guns, keys to super weapons."
VengantMjolnir
 
Posts: 2
Joined: Mon Nov 28, 2005 2:48 am
Location: Canada

Postby jstadolnik on Mon Nov 28, 2005 12:51 pm

jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby VengantMjolnir on Tue Nov 29, 2005 5:03 am

Thanks, I understand the binary to hex number conversion but one thing is bugging me. I'm pretty sure I got it but are the values reversed for some reason?

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
The hex magic decoder ring is as follows:
Bit Value Hex Value
--------- ---------
0000 0 (no bits set)
0001 1 (rightmost bit is 1)
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8 (leftmost bit is 1)
1001 9
1010 a
1011 b
1100 c
1101 d
1110 e
1111 f (all bits set)
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Aren't the hex values read the other way? When I was experimenting with pocketc's built in bitmap function and writing my own bitmaps(to get a hang of how it worked) the bit values went, 0,1,2,4,8.
so I would have read it like this....
0000 0 (no bits set, so far so good)
1000 1
0100 2
1100 3
0010 4
1010 5
0110 6
1110 7
0001 8

you get the idea...
so, you can see where I'm confused I'm sure. in the below example it would be written as 0x7. and thus begins the confusion.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
All hex formatted numbers should be prefixed with "0x".

To set bits 0, 1, and 3 use hex value 0x0000000b (hex b is 1011 binary). You can also just do 0xb, the upper bits are automatically treated as zeroed if unspecified.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

I'm sure its an easy answer but I still have to ask.

"Fourth floor- toys, guns, keys to super weapons."
"Fourth floor- toys, guns, keys to super weapons."
VengantMjolnir
 
Posts: 2
Joined: Mon Nov 28, 2005 2:48 am
Location: Canada

Postby jstadolnik on Tue Nov 29, 2005 11:17 am

An 8 decimal is definitely 1000 in binary, and a 1 decimal is 0001 binary. In binary, the left most side numbers are always the larger magnitude just as in decimal numbers.

You can prove this to yourself on a scientfic calculator which has decimal/hex/binary conversion.

-Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby squib308 on Thu Jul 20, 2006 6:40 pm

quote:
The hex magic decoder ring is as follows:
Bit Value Hex Value
--------- ---------
0000 0 (no bits set)
0001 1 (leftmost bit is 1)
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8 (rightmost bit is 1)
1001 9
1010 a
1011 b
1100 c
1101 d
1110 e
1111 f (all bits set)

------

Err Joe, in your older post, shouldn't this line
0001 1 (leftmost bit is 1)
say "rightmost bit is 1"
and this line
1000 8 (rightmost bit is 1)
say "leftmost bit is 1"
?

Perhaps thats PART of the confusion.. The other bit might be due to the documentation on the bits & the "X:Y" format. I don't totally get it myself, but in another post you whipped out a code snippit to demonstrate the calculation for a button (which is what I'm working on right now) & modified it to ask for the type,frame,group,align variables & give me the result as a hex value.

perhaps if you had a full demo of bit to hex example in the docs -
0123456789abcdef
aggggggggffffttt
a - alignment bit
g - group bits
f - frame bits
t - button type bits
ex:
1000000000100101
right align, no group, sq frame, repeat button

(if I got that right, which is very questionable - my math & my calculator came out with different bits in the 'field' bits)
Then you can stick it in the calculator & convert to hex.

Also it is confusing when in the docs it says "value ... 5" - are we supposed to set bit 5 ( 1000 ), or use a binary number 5 (0101)?

Question : can you use decimal instead of hex if you don't procede it with 0x?

Thanks for all your work and help Joe!
squib308
 
Posts: 4
Joined: Thu Jul 20, 2006 6:03 pm

Postby jstadolnik on Fri Jul 21, 2006 12:38 am

Yeah you're correct, I had the left/right wording backwards. I've corrected that. Thanks for pointing that mistake out.



<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
perhaps if you had a full demo of bit to hex example in the docs -
0123456789abcdef
aggggggggffffttt
a - alignment bit
g - group bits
f - frame bits
t - button type bits
ex:
1000000000100101
right align, no group, sq frame, repeat button

(if I got that right, which is very questionable - my math & my calculator came out with different bits in the 'field' bits)
Then you can stick it in the calculator & convert to hex.

<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

See the below link. I give an exact example of this in the 7th panel.

http://pocketc.net/forum/topic.asp?TOPIC_ID=2095

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
Also it is confusing when in the docs it says "value ... 5" - are we supposed to set bit 5 ( 1000 ), or use a binary number 5 (0101)?
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

The later.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
Question : can you use decimal instead of hex if you don't procede it with 0x?
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Yes.

-Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA


Return to Pocket Toolbox

Who is online

Users browsing this forum: No registered users and 1 guest

cron