Format short difference across two machines

I have a Linux machine running 64 bit MATLAB r2010b and a Windows machine running 32 bit MATLAB r2010a. Both are set with Format short and FormatSpacing loose.
1e-3
returns 1.0000e-03 on the Linux machine and 1.0000e-003 on the Windows machine; the Windows machine has an additional zero after the "e". It is even more confusing since evalc('1e-3') returns the same size character array on both machines but the "e" is the 18th element on the Linux machine and the 17th element on the Windows machine.
While the extra zero after the "e" and the extra space in the output format doesn't matter mathematically, I have been using evalc when writing log files. My log files are turning up different on the two machines causing me headaches.
I would like to know what is causing the difference (r2010a/r2010b, 32/64 bit, Linux/Windows, or something else like screen resolution or window size) and if it has been documented.

2 comentarios

Sean de Wolski
Sean de Wolski el 9 de Jun. de 2011
1.0000e-03
MAC 64bit R2009b.
the cyclist
the cyclist el 9 de Jun. de 2011
1.0000e-03
Mac 64-bit R2011a

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Jun. de 2011

1 voto

In previous discussions this has been attributed to a difference in the Windows OS numeric formatting routine (i.e., as supplied by Microsoft.)

1 comentario

Daniel Shub
Daniel Shub el 10 de Jun. de 2011
This is surprising since engineering format (ShortEng) is consistent but ShortE is not. Was any of this discussion public and do you remember any keywords to guide a search?

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 9 de Jun. de 2011

2 votos

I'm not sure, if it is worth to mention the barely obvious: EVALC is no good choice, if you want to create an exact log file, because you do not have enough control over the output format.
I'm surprised by the "e-03" also, but I understand, why the "e" is at different positions: The string is adjusted to the right.
Solution: FRPINTF with an appropriate %f or %g format.

3 comentarios

Daniel Shub
Daniel Shub el 10 de Jun. de 2011
I was originally using fprintf for logging, but it caused me problems with objects of non-trivial classes. By using evalc, I can use the native disp method for objects of any class to get reasonable formatting and generally enough information for my log file.
For example, consider the disp method for cell objects:
{1, [1:2], 'a', 'abcdefghijk', 'abcdefghijklmnopqrstuvwxyz'}
and
{1, [1:2], 'a', 'abcdefghijk', 'abcdefghijklmnopqrstuvwxyz'}'
I think I am going to continue to use evalc and just do some post processing on the resulting string.
Jan
Jan el 10 de Jun. de 2011
Is there a difference between the results from EVALC, DISP and DISPLAY?
Daniel Shub
Daniel Shub el 10 de Jun. de 2011
EVALC, DISP, and DISPLAY all produce the same thing (1.0000e-03 Linux and 1.0000e-003 Windows).

Iniciar sesión para comentar.

Categorías

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by