Skip to content
EMPS intranet

Back to top
Hi!   Hi!           Start main()

Try stepping through the code


  Value and type of last evaluated expression: Address of array element: Address of array elementx:  (none)

Your browser does not support the canvas element which will make some the features unavailable.

If you are using Internet Explorer within the University of Exeter try going to the Settings menu (probably the gear shape at the top right of this page), selecting "Compatibility View settings", unchecking "Display intranet sites in Compatibility View" and reloading this page.

Code

 Header...
// // Demonstrate complex arithmetic and the complex square root. //
int main(){
  ...
» float xx; » double complex x, y, sqrtx; » x=1.2+3.4*I; » xx=4.3; » y=-13.7*x+5.6*x*x-12.7*I; » sqrtx=csqrt(x); » printf("x is %g %+g * I\n", creal(x), cimag(x)); » printf("y is %g %+g * I\n", creal(y), cimag(y)); » printf("sqrt(x) is %g %+g * I\n", creal(sqrtx), cimag(sqrtx)); » return 0;
}

Data

xx (float)   x (double complex)
132   136
3.99964524e-34
  
2.18847e-314
  y (double complex)
144   152
-5.41817e+266
  
4.24399e-312
  sqrtx (double complex)
160   168
-1.7533e+267
  
-7.07883e+266
176
4.94706e-270

Where two numbers are shown the first is the real part, the second the imaginary.

Memory

main()

132
133
134
135
xx = 3.99964524e-34
136
137
138
139
140
141
142
143
x(r) = 2.18847e-314
144
145
146
147
148
149
150
151
x(i) = -5.41817e+266
152
153
154
155
156
157
158
159
y(r) = 4.24399e-312
160
161
162
163
164
165
166
167
y(i) = -1.7533e+267
168
169
170
171
172
173
174
175
sqrtx(r) = -7.07883e+266
176
177
178
179
180
181
182
183
sqrtx(i) = 4.94706e-270

NB: the actual memory address of each variable is the
address shown plus 4288711712 (0xFFA08C20).

Show Advanced options

.
Show output (Before looking at the output, work out what you think it put should be and see if you are right.)

Output

x is  1.2 +3.4 * I
y is  -73.112 -13.584 * I
sqrt(x) is 1.55009 +1.09671 * I
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Share
Back to top