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 CCS Technical Support

float data ,,and CTRL-Z

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



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

float data ,,and CTRL-Z
PostPosted: Mon Mar 26, 2007 4:32 am     Reply with quote

hi all

Code:


float value = 1111.0123;
      printf("%04.3f",value);

this is the output.
Quote:
1111.025

whats wrong???

other question:

when i printf (\r\n) they have some mean (show in hypertermianl)
i need to add

Quote:

Character Description Decimal Octal Hex Binary
CTRL-Z Substitute, exit 26 032 0x1a 0001 1010


how to do???
i try to do the following:
Code:


      printf("%x",0x1a);




but its return wrong value
Ttelmah
Guest







PostPosted: Mon Mar 26, 2007 7:11 am     Reply with quote

I'm suprised it is quite as far 'out' as 1111.025, but the problem is the basic precision of floating point. There are only just under 24bits used to store the actual 'number' (as opposed to the exponent with it), and this gives just over 6 digits of basic precision.

Look in a standard 'C' book. The '\' codes, are standard. \r, is a 'carriage return'. \n, is a 'new line. \t is a tab, \f is a 'form feed'. etc..

The %x fomat in printf, means 'translate the character to _hex_. Not what you are after. You want to send the raw character in binary. Use:

putc(0x1a);

or

printf("%c",0x1a);

or

printf("\x1a"); //note no zero for this one

Best Wishes
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

PostPosted: Tue Mar 27, 2007 6:03 am     Reply with quote

thank you
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