CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

printf binary format

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hamid9543



Joined: 31 Jan 2013
Posts: 63

View user's profile Send private message

printf binary format
PostPosted: Sat Apr 24, 2021 12:15 pm     Reply with quote

unsigned int8 a; (or int16)
How to print binary number via printf ?
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Apr 24, 2021 12:42 pm     Reply with quote

A simple search would have found your answer:
http://www.ccsinfo.com/forum/viewtopic.php?t=55296&highlight=printf+binary
_________________
Google and Forum Search are some of your best tools!!!!
hamid9543



Joined: 31 Jan 2013
Posts: 63

View user's profile Send private message

PostPosted: Sun Apr 25, 2021 12:10 pm     Reply with quote

dyeatman wrote:
A simple search would have found your answer:
http://www.ccsinfo.com/forum/viewtopic.php?t=55296&highlight=printf+binary


Sad Sad I searched but i don't found anythings!!! how you search in forum ? I searched "printf binary format"
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Apr 25, 2021 12:40 pm     Reply with quote

hmm.

in the search box... 'printf binary format'
select 'search for all terms'

produces 69 'hits' for me
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Apr 26, 2021 1:32 am     Reply with quote

Problem is that by default, the search is set to 'search for any term', which
means it will give thousands of hits that have nothing to do with what is
required. The other issue, is that actually the 'answer' is nothing to do
with printf. Printf itself has no binary output form. What the compiler has
is the standard C function that allows you to output a value into any
numeric format. If you searched for 'binary string format', and 'search for
all terms', the very first hit contains the 'answer'.
In fact the other very powerful way to search is to use Google.

Put into this:

forum:ccsinfo.com binary number output

The whole first page is full of correct answers. Very Happy
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Apr 26, 2021 5:27 am     Reply with quote

hmm, I have to wonder, why CCS doesn't have the 'print in binary format' option for the printf() function ? It's kinda the 'base' level way to display 'data'....ones and zeros, bit by bit......
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Apr 26, 2021 5:45 am     Reply with quote

Basically because it was not part of C.
K&R obviously did not expect anyone to actually want to do this.
The capability is there to do this with itoa, as part of a more generic
ability to output data in any numeric format, but was never a printf
formatter.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group