When reading from file with the "mfscanf(-1, fd, "%e\n")" function
the numbers "-101061877.000000" and "970551467.000000" represented by
"- 1.011D+08" and "9.706D+08". When I trying to divide them for example
by 1000000 the results are "- 101.06188" and "970.55149" respectively.
How to increase accuracy of reading?
Thanks a lot,
Y.B.
I believe your problem is just a display problem.
See help format.
Example:
-->a=-101061877.000000
a =
- 1.011E+08
-->a/1000000
ans =
- 101.06188
-->format("e",15)
-->a/1000000
ans =
- 1.01061877E+02
HTH
Francois
"Yuri Belenky" <n...@spam.net> a écrit dans le message de news:
dk59qg$doi$1...@domitilla.aioe.org...
A clumsy work around might be to read al your data in as strings and then use
execstr to convert them to numbers:
-->a=msscanf("970551467.00000","%e")
a =
9.706E+08
-->b=a/1000000
b =
970.55149
-->execstr("a=970551467.00000")
-->b=a/1000000
b =
970.55147
-->
And maybe submit a bug report...
I have some functions who implement that (needed that because of speed issues
and a (submitted) bug that crashed scilab on MSwindows on certain big numbers).
It's not a replacement for mfscanf through. You will have to do some work
yourself. If you want them, ask.
wfg,
Gaspard
On Mon, 31 Oct 2005, Francois Vogel wrote:
> Reading from file should be in the correct format, I mean, no precision is
> lost in this process if the correct format parameters are sent to mfscanf.
>
> I believe your problem is just a display problem.
Apparently not:
-->a=msscanf("970551467.00000","%e")
a =
9.706E+08
-->a/1000000
ans =
970.55149
-->format("e",15)
-->a/1000000
ans =
9.70551488E+02
-->a=msscanf("970551467.00000","%15e")
a =
9.70551488E+08
Or is there something I miss? I must admit it is on scilab 3.0...
wfg,
Gaspard
How interesting... Same result on my very recent cvs version.
Could be bug 1315, or maybe 583.
Francois
> Reading from file should be in the correct format, I mean, no precision is
> lost in this process if the correct format parameters are sent to mfscanf.
>
> I believe your problem is just a display problem.
>
> See help format.
No, the OP is correct.
-->format(20)
-->fd=mopen("a.dat");b=mfscanf(-1, fd, "%e\n"),mclose(fd);
b =
! - 101061880. !
! 970551488. !
-->fd=mopen("a.dat");b=mfscanf(-1, fd, "%f\n"),mclose(fd);
b =
! - 101061880. !
! 970551488. !
-->fd=mopen("a.dat");b=mfscanf(-1, fd, "%g\n"),mclose(fd);
b =
! - 101061880. !
! 970551488. !
however note that:
-->fd=mopen("a.dat");b=mfscanf(-1, fd, "%d\n"),mclose(fd);
b =
- 101061877.
-->fd=mopen("a.dat");b=mfscanf(-1, fd, "%d.\n"),mclose(fd); b =
! - 101061877. !
! 0. !
! 970551467. !
! 0. !
And
-->read("a.dat",-1,1)
ans =
! - 101061877. !
! 970551467. !
Pehaps mfscanf implements a float read instead of a double?
Enrico