Complex variable assignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Sirs,

I have wrote a simple program that assigns a complex number a number in the form of a + b*I
and when I print it the numbers I noticed loss of precision. It does not seem it is recognizing it as a double.

#include <stdio.h>
#include <math.h>
#include <complex.h>

int main (int argc, const char * argv[]) {
	
	complex double  y[1][1];
	
	y[0][0] = (double) -0.107692307692308 + (double) 0.061538461538462*I;
	
	printf("\n------------------- Complex Array Assignment ---------------------------------------------------\n");
        printf("\n(%+10.15f,%+10.15f)", crealf(y[0][0]), cimagf(y[0][0]));
	printf("\n");
	printf("\n\n----------------------------------------------------------------------------------------------\n");
	
	
    return 0;
}

This is what you will get:

------------------- Complex Array Assignment ---------------------------------------------------

(-0.107692308723927,+0.061538461595774)


----------------------------------------------------------------------------------------------


I have attached the file and my compiler is:
i686-apple-darwin10-gcc-4.2.1

-Amin Al-Juffali
ajuffali@xxxxxxx

Attachment: complexTest.c
Description: Binary data


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux