0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C > complex.h > 複素数を代入してprintfする > dcval = 3.14 + 1.592 * I; / creal(dcval) / cimag(dcval)

Last updated at Posted at 2016-12-16
My_Environment
Ubuntu 14.04 LTS Japanese Remix
GNU bash, version 4.3.11(1)-release

gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 
(also for g++)

#include <complex.h>で複素数を扱っているコードの作業をしている。

complex型の扱いはほとんど覚えていないのでとりあえず代入とprintfまで確認した。

参考 http://stackoverflow.com/questions/6418807/how-to-work-with-complex-numbers-in-c

stduy_complex.c
#include <stdio.h>
#include <stdlib.h>
#include <complex.h>

int main(int argc, char *argv[])
{
	double complex dcval;

	dcval = 3.14 + 1.592 * I;

	printf("%f %f\n", creal(dcval), cimag(dcval));

}
実行
$ gcc study_complex.c && ./a.out 
3.140000 1.592000
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?