Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   One line power (http://www.chiefdelphi.com/forums/showthread.php?t=2627)

ChrisA 13-03-2002 14:51

heres a rule of thumb for ya...
if mike soukup replies to your post with code in it, it will usually be in either c or c++. (thats bout all he normally codes in).
(you know its true mike :D )

so actually your question was answered before you even asked it even though it was hidden from view.
:)

VanWEric 13-03-2002 17:11

One furthur Digression
 
I know this is a little off topic, but in PBASIC i can directly edit the bits of a byte -- my_variable.bit7 directly mucks around with bit 7 of that variable. Can i do this in c++? most of the code i write in pbasic gets a speed boost from mucking with it that way. Sorry about the tangent.

srawls 13-03-2002 18:13

In C or C++ you can do it "the hard way"
my_var & 2^bit_wanted (assuming bit0 is least significant bit)
note: above ^ is not XOR but is 2 raised to some power
but that isn't an lvalue, so you can't "directly muck around with it."

Another option is to use bitfields. I haven't done that in a while, and I don't have a book infront of me, so I won't try to post an example. If I remember correctly, though, you aren't able to specify which bit number each variable refers to, but you can mimmick the effect if you don't rely on bit7 to be the 7th bit.

Stephen


All times are GMT -5. The time now is 17:37.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi