|
|
View previous topic :: View next topic |
Author |
Message |
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
float data ,,and CTRL-Z |
Posted: Mon Mar 26, 2007 4:32 am |
|
|
hi all
Code: |
float value = 1111.0123;
printf("%04.3f",value);
|
this is the output.
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:
but its return wrong value |
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 26, 2007 7:11 am |
|
|
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
|
|
Posted: Tue Mar 27, 2007 6:03 am |
|
|
thank you |
|
|
|
|
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
|