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

Print value in it's binary form

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



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

Print value in it's binary form
PostPosted: Tue Mar 30, 2004 3:16 pm     Reply with quote

Is there a % format for printing an int16 in it's binary form? I searched the forum with no answer and I'm drawing a mental blank.

Hex would print as: 10FF
Binary would print as: 1000000011111111

Thanks.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Tue Mar 30, 2004 3:54 pm     Reply with quote

I know it's a odd to hear but did you look in the manual? If it's not there it should be in the readme file.
random_person
Guest







PostPosted: Tue Mar 30, 2004 3:58 pm     Reply with quote

I'm not sure there is as I've had to ask the same question myself.

According to the CCsC.hlp file, there is no explicit binary printf type.

You could write a function to translate bits to chars and to printf one character (ascii 1 or ascii 0) per 16 times. or you could make a string of 16 chars of 1/0 and printf the string...but that would require 16+ bytes of RAM.

Of course, if there is a better way, i'd be happy to hear about it, too! Smile
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Tue Mar 30, 2004 4:02 pm     Reply with quote

Neutone wrote:
I know it's a odd to hear but did you look in the manual? If it's not there it should be in the readme file.


Definitely looked both places and definitely didn't find it. My memory is not as good as it used to be so I was hoping I had just forgotten the trick. I felt the forum was the next option.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 30, 2004 4:34 pm     Reply with quote

There is code on the forum. This thread has a routine
to convert an 8-bit value to ASCII binary representation.
You could modify it to work with a 16-bit input value.
http://www.ccsinfo.com/forum/viewtopic.php?t=1523&highlight=convert+binary
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Tue Mar 30, 2004 5:16 pm     Reply with quote

PCM programmer wrote:
There is code on the forum....


Thanks PCM. Since it looks like it will require extra code, I'm going to rethink my application to use an existing format.
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