Jak np. mam takie coś:
Kod: Zaznacz cały
var i = Math.Sqrt(-1); // Jaki typ w miejsce var?
var inf = Double.Inf;
var negative_inf = -(Double.Inf);
var nan = 2 / 0; // Jaki to typ zmiennej?
Kod: Zaznacz cały
var i = Math.Sqrt(-1); // Jaki typ w miejsce var?
var inf = Double.Inf;
var negative_inf = -(Double.Inf);
var nan = 2 / 0; // Jaki to typ zmiennej?
Kod: Zaznacz cały
#include <stdio.h>
#include <complex.h>
#include <tgmath.h>
int main(void)
{
double complex z1 = I * I; // imaginary unit squared
printf("I * I = %.1f%+.1fi\n", creal(z1), cimag(z1));
double complex z2 = pow(I, 2); // imaginary unit squared
printf("pow(I, 2) = %.1f%+.1fi\n", creal(z2), cimag(z2));
double PI = acos(-1);
double complex z3 = exp(I * PI); // Euler's formula
printf("exp(I*PI) = %.1f%+.1fi\n", creal(z3), cimag(z3));
double complex z4 = 1+2*I, z5 = 1-2*I; // conjugates
printf("(1+2i)*(1-2i) = %.1f%+.1fi\n", creal(z4*z5), cimag(z4*z5));
}
Kod: Zaznacz cały
I * I = -1.0+0.0i
pow(I, 2) = -1.0+0.0i
exp(I*PI) = -1.0+0.0i
(1+2i)*(1-2i) = 5.0+0.0i
complex
, zaś do operacji na nim — biblioteka Kod: Zaznacz cały
https://docs.python.org/3.4/library/cmath.html
float
.