This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Question for displaying floating point in eCOSaplication. Thanks a lot


Thanks Gary.
 I tried this as followings:

// Program as

double test_double=4.00;
float test_float=4.00;
cyg_uint32 test_data = 0x40800000;
float cov_data=0.00;
cov_data = ((float)test_data);
printf("test_double = %f, test_float = %f\n", test_double, test_float);
printf("test_double=0x%llx, test_float=0x%llx\n", test_double, test_float);
printf("test_data = %f, test_data = 0x%llx\n", (float)test_data, test_data);
printf("cov_data = %f, cov_data = 0x%llx\n", cov_data, cov_data);
printf("test_double size: %d, test_float size: %d\n", sizeof(test_double),
sizeof(test_float));
printf("double size: %d, float size: %d\n", sizeof(double), sizeof(float));


// output as

test_double = 4.000000, test_float = 4.000000
test_double=0x40100000, test_float=0x40100000
test_data = 1082130432.000000, test_data = 0x40800000
cov_data = 1082130432.000000, cov_data = 0x41d02000
test_double size: 8, test_float size: 4
double size: 8, float size: 4


seems the size of double and float is different but why they store the data
with the same format (not as the standard floating point and double in IEEE
STD)? Am I wrong here? Any idea?


thanks a lot.


-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Gary Thomas
Sent: 07 August 2003 15:25
To: QiangHuang
Cc: Andrew Lunn; eCos Discussion
Subject: RE: [ECOS] Question for displaying floating point in
eCOSaplication. Thanks a lot


On Thu, 2003-08-07 at 08:20, QiangHuang wrote:
> Hi:
>
> Another more comprehensive try:
>
> double test_double=4.00;
> float test_float=4.00;
> cyg_uint32 test_data = 0x40800000;
> float cov_data=0.00;
> cov_data = ((float)test_data);
> printf("test_double = %f, test_float = %f\n", test_double, test_float);
> printf("test_double=0x%llx, test_float=0x%llx\n", test_double,
test_float);
> printf("test_data = %f, test_data = 0x%llx\n", (float)test_data,
test_data);
> printf("cov_data = %f, cov_data = 0x%llx\n", cov_data, cov_data);
>
> // Output as:
> test_double = 4.000000, test_float = 4.000000
> test_double=0x40100000, test_float=0x40100000
> test_data = 1082130432.000000, test_data = 0x40800000
> cov_data = 1082130432.000000, cov_data = 0x41d02000
>
> seems no matter I set the variable to either float or double they are
using
> the same format as real*8, is this the case?
>

Most likely, the compiler is storing both 'float' and 'double' the
same on this architecture.  [Note: I've not verified this myself]

What is 'sizeof(double)' and 'sizeof(float)'?

--
Gary Thomas <gary@mlbassoc.com>
MLB Associates


--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]