LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-01-2012, 03:05 AM   #1
alvfaceb
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Rep: Reputation: Disabled
bit treatment of an uint32_t


Hi everyone,

I'm programming an application and I need to find the i-esim 0 of a uint32_t. How can I do it? maybe some function that converts to a char[]?

Thanks for any help/comment!!
 
Old 02-01-2012, 06:24 AM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,547
Blog Entries: 3

Rep: Reputation: 811Reputation: 811Reputation: 811Reputation: 811Reputation: 811Reputation: 811Reputation: 811
What on earth is "i-esim 0"?

For locating and counting individual bits, look up __builtin_ffs(), __builtin_clz(), __builtin_ctz() and __builtin_popcount(). While they are GCC built-ins, they are supported by most other C compilers too.

Each of these operations can be written using portable code in a few lines; most of them are listed in Wikipedia, others in different optimization articles all over the web. The variant I'd recommend would heavily depend on exactly what you need to find out. It is a good bet that the compiler builtins are faster, though.
 
Old 02-09-2012, 05:10 AM   #3
alvfaceb
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
thanks, it did work

btw, the i-esim 0 means the 0 in the i position of the array.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unsigned long int uint32_t to unsigned char and back MicahCarrick Programming 2 08-02-2009 01:39 AM
The best acne treatment CedInfere Linux - General 2 06-30-2007 07:45 PM
Treatment for help Patrick V. Tony_Alrod Slackware 2 12-20-2004 12:49 PM


All times are GMT -5. The time now is 11:20 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration