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

Octal numbers

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



Joined: 08 Sep 2003
Posts: 9
Location: Birmingham, UK

View user's profile Send private message

Octal numbers
PostPosted: Wed May 21, 2003 3:54 am     Reply with quote

Dear all

Is it possible to convert a hex or binary int(8bits) to octal format using CCS.

0b11000110
=
0(octal?)306

Or am i going to have to do some more bit manipulating.

Regards

Paul_B
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514623
Tomi
Guest







Re: Octal numbers
PostPosted: Wed May 21, 2003 4:35 am     Reply with quote

I use this:
void Bin2Octal(char binar, char *outstr)
{
outstr[0] = (binar >> 6) + '0';
outstr[1] = ((binar >> 3) & 0x07) + '0';
outstr[2] = (binar & 0x07) + '0';
outstr[3] = 0;
}

Usage:
char i,outp[4];
i = 0x54;
Bin2Octal(i,outp);


:=Dear all
:=
:=Is it possible to convert a hex or binary int(8bits) to octal format using CCS.
:=
:=0b11000110
:==
:=0(octal?)306
:=
:=Or am i going to have to do some more bit manipulating.
:=
:=Regards
:=
:=Paul_B
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514624
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