Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread gabor via fpc-pascal
W dniu 2022-02-21 o 13:34, gabor via fpc-pascal pisze: W dniu 2022-02-21 o 13:18, Ryan Joseph via fpc-pascal pisze: Oh my, I was confusing my terms I think. I wanted to do bit masking (I think it's called). I was expecting there to be something like TestFlag in the RTL since I can never rememb

Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread Mattias Gaertner via fpc-pascal
On Mon, 21 Feb 2022 13:34:29 +0100 gabor via fpc-pascal wrote: > W dniu 2022-02-21 o 13:18, Ryan Joseph via fpc-pascal pisze: > > Oh my, I was confusing my terms I think. I wanted to do bit masking > > (I think it's called). I was expecting there to be something like > > TestFlag in the RTL since

Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread Ryan Joseph via fpc-pascal
> On Feb 21, 2022, at 7:31 PM, Michael Van Canneyt via fpc-pascal > wrote: > > Hm. I'm not sure that this code does what you need. > > But masking is indeed not in the helpers. > Try it yourself, it does indeed work. How else are you supposed to test these kinds of bit flag APIs where all

Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread gabor via fpc-pascal
W dniu 2022-02-21 o 13:18, Ryan Joseph via fpc-pascal pisze: Oh my, I was confusing my terms I think. I wanted to do bit masking (I think it's called). I was expecting there to be something like TestFlag in the RTL since I can never remember the syntax "Value = (Value or Index)" function Tes

Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread Michael Van Canneyt via fpc-pascal
On Mon, 21 Feb 2022, Ryan Joseph via fpc-pascal wrote: On Feb 21, 2022, at 7:01 PM, Michael Van Canneyt via fpc-pascal wrote: Yes, this is testbit. Why do you say it does not work ? Oh my, I was confusing my terms I think. I wanted to do bit masking (I think it's called). I was expec

Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread Ryan Joseph via fpc-pascal
> On Feb 21, 2022, at 7:01 PM, Michael Van Canneyt via fpc-pascal > wrote: > > Yes, this is testbit. > > Why do you say it does not work ? Oh my, I was confusing my terms I think. I wanted to do bit masking (I think it's called). I was expecting there to be something like TestFlag in the RT

Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread Michael Van Canneyt via fpc-pascal
On Mon, 21 Feb 2022, Ryan Joseph via fpc-pascal wrote: I tried to use the bit helpers like https://www.freepascal.org/docs-html/rtl/sysutils/twordhelper.testbit.html but the bit to test is 0..15. There are only 16 bits in a word, so that is correct. I expected this to work like https://wi

[fpc-pascal] Bit manipulation helpers

2022-02-21 Thread Ryan Joseph via fpc-pascal
I tried to use the bit helpers like https://www.freepascal.org/docs-html/rtl/sysutils/twordhelper.testbit.html but the bit to test is 0..15. I expected this to work like https://wiki.freepascal.org/Bit_manipulation but that doesn't seem to be the case. Does there exist bit helpers like GetBi

Re: [fpc-pascal] Bit manipulation

2006-02-21 Thread Steve Williams
Florian Klaempfl wrote: Geno Roupsky wrote: it is as simple as this: function isset(value: dword; bit: byte): boolean; begin result := value and (1 shl pred(bit)) <> 0; end; Adding inline doesn't hurt speedwise ;) It is also assuming that bit counting starts at 1. I'd remove t

Re: [fpc-pascal] Bit manipulation

2006-02-21 Thread Florian Klaempfl
Geno Roupsky wrote: > it is as simple as this: > > function isset(value: dword; bit: byte): boolean; > begin > result := value and (1 shl pred(bit)) <> 0; > end; Adding inline doesn't hurt speedwise ;) > > 2006/2/20, Pianoman <[EMAIL PROTECTED] >: > > Hi, I need

Re: [fpc-pascal] Bit manipulation

2006-02-21 Thread Geno Roupsky
it is as simple as this: function isset(value: dword; bit: byte): boolean; begin   result := value and (1 shl pred(bit)) <> 0; end;2006/2/20, Pianoman <[EMAIL PROTECTED]>: Hi, I need to know how can I see whether a certain bit of byte/word/dword isset:  or not:function like this would be appreciat

Re: [fpc-pascal] Bit manipulation

2006-02-20 Thread Jonas Raoni
On 2/20/06, Pianoman <[EMAIL PROTECTED]> wrote: > Hi, I need to know how can I see whether a certain bit of byte/word/dword is > set: or not: > function like this would be appreciated: > function isset(value: byte word or dword;bit:byte):boolean; > for example when i pass the function parrameter a

[fpc-pascal] Bit manipulation

2006-02-20 Thread Pianoman
Hi, I need to know how can I see whether a certain bit of byte/word/dword is set: or not: function like this would be appreciated: function isset(value: byte word or dword;bit:byte):boolean; for example when i pass the function parrameter a of type word and I want to see whether the bit 14 is set.