2
$\begingroup$

I noticed that the output from wolframscript appears to be different when running interactively and when running with code in a file.

I tried searching for this, but it's a bit hard to describe, so I didn't find anything.

Here is an example of the interactive output, which looks normal to me.

$ wolframscript 
Wolfram Language 12.1.0 Engine for Mac OS X x86 (64-bit)
Copyright 1988-2020 Wolfram Research, Inc.

In[1]:= Print[N[1/7,50]]                                                                                                                                                                                                                                    
0.14285714285714285714285714285714285714285714285714

Here is the output when the code is in a file

$ echo 'Print[N[1/7,50]]' > code && wolframscript -file code
0.14285714285714285714285714285714285714285714285714285714285714285714285714285`50.

I don't understand where the suffix 285714285714285714285714285`50. comes from and I don't know how to get rid of it.

$\endgroup$

1 Answer 1

3
$\begingroup$

It's because Print keeps the NumberMarks. Change your code to disable them:

Print[ToString[N[1/7, 50], NumberMarks -> False]]
(* result: 0.14285714285714285714285714285714285714285714285714 *)
$\endgroup$
1
  • $\begingroup$ It seems that ToString by itself is sufficient, but thanks for mentioning that the extra substring was a number mark, because I didn't know what to call it. $\endgroup$
    – SirBogman
    Commented Jun 23, 2020 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.