Bit count funtion in 18F series

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
NAGARSU5
Posts: 12
Joined: 19 Nov 2016 05:06

Bit count funtion in 18F series

#1 Post by NAGARSU5 » 18 Sep 2023 03:32

Hi,

Is there any specific funtion code to count number of active bits in the register?. If have, please do share the codes or the library. Im doing one project, which requires to count the active bits and gets displayed on the LCD.

Thanks,

Sutha

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Bit count funtion in 18F series

#2 Post by filip » 22 Sep 2023 07:15

Hi,

What do you mean by active bits exactly ?

Regards,
Filip.

NAGARSU5
Posts: 12
Joined: 19 Nov 2016 05:06

Re: Bit count funtion in 18F series

#3 Post by NAGARSU5 » 23 Sep 2023 05:38

Hi filip,

The active bits are those true bits .

Best regards,

Sutha

NAGARSU5
Posts: 12
Joined: 19 Nov 2016 05:06

Re: Bit count funtion in 18F series

#4 Post by NAGARSU5 » 02 Oct 2023 04:33

Hi Filip,

Any updates for this?

Regards,

Sutha

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Bit count funtion in 18F series

#5 Post by filip » 20 Oct 2023 13:03

Hi,

Sorry for the delay. By true bits you mean the ones that are set to 1 ?

Regards,
Filip.

NAGARSU5
Posts: 12
Joined: 19 Nov 2016 05:06

Re: Bit count funtion in 18F series

#6 Post by NAGARSU5 » 02 Nov 2023 01:05

Hi Filip,

Yes you're right. For example > 01011011 = So the result should be 5.

Best Regards,

Sutha

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Bit count funtion in 18F series

#7 Post by filip » 02 Nov 2023 10:08

Hi,

There is no such function I'm afraid, but you can implemented by yourself - simply by testing each bit in a variable and increment a counter if condition is met.

Regards,
Filip.

Post Reply

Return to “mikroBasic PRO for PIC General”