Question: Saving complex numbers with fprintf while imposing .precision

Hi all.

Ok, I'm trying to save to a file a set of a complex number, a float number and an integer. According to Maple Help this can be done with:

writedata[append]('terminal',[-0.123456-0.123456*I, 0.1334423423*10^(-15),3], float, proc(f,x) fprintf(f,`%a`,x) end proc);

And it works (the numbers are just an example of what I'm trying to do).

The problem is that I want to change the precision of the second number (or to all of them) to say 5 digits. But when I try as the help suggests:

writedata[append]('terminal',[-0.123456-0.123456*I, 0.1334423423*10^(-15),3], float, proc(f,x) fprintf(f,`%.5a`,x) end proc);

I get:

-.123
1.334423423e-16
3
Obviously, the precision is imposed only to the first number and not to all. I tried all afternoon to do it the way I want to, but unfortunately I don't understand that much from C routines and I dramatically fail so far.

Any ideas, suggestions or common sense of something I obviouly miss?

 

Please Wait...