# Formatting numbers in wolframscript command-line output

I am trying to run the following code using wolframscript on windows:

a = 123.4567891011213;
Print["a = ",a];
Print["a = ",AccountingForm[a,3]];


The output is:

a = 123.4567891011213
a = AccountingForm[123.4567891011213, 3]


Looks like none of the formatting commands work (e.g. I tried StringForm and it too remains unevaluated). I would just like to format the numbers to be a little shorter. Is it possible?

• It works for me, output is a = 123.. What version are you using? – Rohit Namjoshi Oct 18 '19 at 1:56
• 1.2.0 for Windows. – Mattia Landoni Oct 18 '19 at 2:05
• 1.2.0? Did you mean 12.0? What does $Version evaluate to? – Rohit Namjoshi Oct 18 '19 at 2:10 • My Mathematica version is 12.0.0 for Microsoft Windows (64-bit) (April 6, 2019). My Wolframscript version (typing wolframscript --version at the command line prompt) is WolframScript 1.2.0 for Windows. – Mattia Landoni Oct 18 '19 at 2:15 • That is strange. I am on Mac OS, but that should not matter. I see Wolfram Language 12.0.0 Engine for Mac OS X x86 (64-bit) Copyright 1988-2019 Wolfram Research, Inc. In[1]:= a = 123.4567891011213; In[2]:= Print["a = ",a]; a = 123.457 In[3]:= Print["a = ",AccountingForm[a,3]]; a = 123. – Rohit Namjoshi Oct 18 '19 at 2:23 ## 1 Answer User Szabolcs's answer to this other question I asked yesterday also solves this problem. The underlying cause is that default output format is ScriptForm and not OutputForm as it should be. To manually correct this behavior, it is enough to add SetOptions[$Output, FormatType -> OutputForm] at the beginning of the script.

• Later on Wolfram got back to me. They said that upgrading Wolframscript to version 1.3.0 also solves the problem. (This is on Windows. As far as I can tell this was a Windows-only problem). – Mattia Landoni Oct 22 '19 at 5:01
• It doesn't work in version 1.3.0. However changing the OutputForm seems to be great solution. – Sâu Oct 22 '19 at 8:18