Sponsored Content
Top Forums Programming Comparing unsigned char bits. Post 302624747 by robin_simple on Monday 16th of April 2012 06:39:45 PM
Old 04-16-2012
Code:
#include <stdio.h>
int main()
{
    unsigned char a,b;
    a = 1 + 2 + 4 + 16 + 32 + 64 + 128;
    b=1;

    while(b<=128)
    {
        if(a & b)
            printf("%d\n", b);

        if(b == 128)
            b = b + 1;
        else
            b = b * 2;
    }
}

I'm using something like this code to mark each bit position with one of the powers of two and then comparing the byte with a combination of each power of two. Thanks for the help. I'm probably not very clear about what I'm talking about.
 

8 More Discussions You Might Find Interesting

1. Programming

Unsigned int

How can I store and/or print() a number that is larger than 4 294 967 295 in C? is int64_t or u_int64_t what I need ? if, so how can I printf it to stdout? (2 Replies)
Discussion started by: nimnod
2 Replies

2. UNIX for Dummies Questions & Answers

Changing 24 bits to 8 bits display

Hello all, I was wondering if anyone can tell me how to change 24 bits depth display to 8 bits depth display for Sun Ultra1, running Solaris 8? THANKS in advance. I think that the command is ffbconfig, but it has nothing about depth. (4 Replies)
Discussion started by: larry
4 Replies

3. Programming

to get the correct value with unsigned int

hi, Please help me with the following code to get the difference in values. struct a{ int b1; int c1; char d1; } main() { unsigned int b=10; unsigned int c; c = b - (unsigned int )sizeof(a); printf("%d",c); } Here c returns some junk value. How can i get the... (2 Replies)
Discussion started by: naan
2 Replies

4. UNIX for Dummies Questions & Answers

32 bits procesaor with 64 bits Solaris

people i have a problem i have a 32 bits sparc processor, and solaris 64 bits processor, i install a oracle data base 64 bits, but my oracle will not run because my processor is from 32 bits this is ok??, i know if i have x86 i cannot install a 64 bits operatin system in a 32 bits processor. ... (0 Replies)
Discussion started by: enkei17
0 Replies

5. Programming

Help with understanding ( int, char, long, short, signed, unsigned etc.... )

My question is simple: When should I use a long, int, char, unsigned/signed variables?? When I declare a variable "unsigned;" what did I do it??? Why would I delcare an integer "long" or "short" ( unsigned or signed)?? Any examples of when things like "unsigned", "long", "short" etc...... (6 Replies)
Discussion started by: cpp_beginner
6 Replies

6. Programming

Signed and unsigned intergers

when a date type is considered signed and unsigned is that simple referring to - for signed and positive numbers for unsigned? Further if that is the case would mutiplying and dividing ect where 2 signed numbers, like (-2)*(-2) = 4 result in a unsigned. (3 Replies)
Discussion started by: Fingerz
3 Replies

7. What is on Your Mind?

Place Bits & Win Bits!!! - 17th Annual Satellite Awards

Ten movies have been nominated as best motion picture by the International Press Academy, presentation of the 2012 Satellite Awards will be held on 16th December at Los Angeles, CA. Place your bits here on one of the below nominated movie of your choice:- Argo ... (0 Replies)
Discussion started by: Yoda
0 Replies

8. OS X (Apple)

Unsigned to signed, error?...

Hi guys... Macbook Pro, 13", circa August 2012, OSX 10.7.5, default bash terminal. I require the capability to convert +32767 to -32768 into signed hex words... The example piece code below works perfectly except... #/bin/bash # sign.sh # Unsign to sign... while true do # I have used... (2 Replies)
Discussion started by: wisecracker
2 Replies
PAPI_component_info_t(3)					       PAPI						  PAPI_component_info_t(3)

NAME
PAPI_component_info_t - SYNOPSIS
Data Fields char name [128] char short_name [64] char description [128] char version [64] char support_version [64] char kernel_version [64] char disabled_reason [128] int disabled int CmpIdx int num_cntrs int num_mpx_cntrs int num_preset_events int num_native_events int default_domain int available_domains int default_granularity int available_granularities int hardware_intr_sig int component_type int reserved [8] unsigned int hardware_intr:1 unsigned int precise_intr:1 unsigned int posix1b_timers:1 unsigned int kernel_profile:1 unsigned int kernel_multiplex:1 unsigned int fast_counter_read:1 unsigned int fast_real_timer:1 unsigned int fast_virtual_timer:1 unsigned int attach:1 unsigned int attach_must_ptrace:1 unsigned int cntr_umasks:1 unsigned int cpu:1 unsigned int inherit:1 unsigned int reserved_bits:12 Detailed Description Field Documentation unsigned int PAPI_component_info_t::attach Supports attach unsigned int PAPI_component_info_t::attach_must_ptrace Attach must first ptrace and stop the thread/process int PAPI_component_info_t::available_domains Available domains int PAPI_component_info_t::available_granularities Available granularities int PAPI_component_info_t::CmpIdx Index into the vector array for this component; set at init time unsigned int PAPI_component_info_t::cntr_umasks counters have unit masks int PAPI_component_info_t::component_type Type of component unsigned int PAPI_component_info_t::cpu Supports specifying cpu number to use with event set int PAPI_component_info_t::default_domain The default domain when this component is used int PAPI_component_info_t::default_granularity The default granularity when this component is used char PAPI_component_info_t::description[128] Description of the component int PAPI_component_info_t::disabled 0 if enabled, otherwise error code from initialization char PAPI_component_info_t::disabled_reason[128] Reason for failure of initialization unsigned int PAPI_component_info_t::fast_counter_read Supports a user level PMC read instruction unsigned int PAPI_component_info_t::fast_real_timer Supports a fast real timer unsigned int PAPI_component_info_t::fast_virtual_timer Supports a fast virtual timer unsigned int PAPI_component_info_t::hardware_intr hw overflow intr, does not need to be emulated in software int PAPI_component_info_t::hardware_intr_sig Signal used by hardware to deliver PMC events unsigned int PAPI_component_info_t::inherit Supports child processes inheriting parents counters unsigned int PAPI_component_info_t::kernel_multiplex In kernel multiplexing unsigned int PAPI_component_info_t::kernel_profile Has kernel profiling support (buffered interrupts or sprofil-like) char PAPI_component_info_t::kernel_version[64] Version of the kernel PMC support driver char PAPI_component_info_t::name[128] Name of the component we're using int PAPI_component_info_t::num_cntrs Number of hardware counters the component supports int PAPI_component_info_t::num_mpx_cntrs Number of hardware counters the component or PAPI can multiplex supports int PAPI_component_info_t::num_native_events Number of native events the component supports int PAPI_component_info_t::num_preset_events Number of preset events the component supports unsigned int PAPI_component_info_t::posix1b_timers Using POSIX 1b interval timers (timer_create) instead of setitimer unsigned int PAPI_component_info_t::precise_intr Performance interrupts happen precisely char PAPI_component_info_t::short_name[64] Short name of component, to be prepended to event names char PAPI_component_info_t::support_version[64] Version of the support library char PAPI_component_info_t::version[64] Version of this component Author Generated automatically by Doxygen for PAPI from the source code. Version 5.2.0.0 Tue Jun 17 2014 PAPI_component_info_t(3)
All times are GMT -4. The time now is 12:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy