10
$\begingroup$

Does anybody have an idea what the meaning of the second argument of Internal`DoubleToString might be? It accepts also a third argument which seems to be related to the number of leading digits that are to be printed, but even that is not very clear to me if there is no third argument provided:

Internal`DoubleToString[1. Pi 10^6]
Internal`DoubleToString[1. Pi 10^-3]
Internal`DoubleToString[1. Pi 10^6, 1, 5]
Internal`DoubleToString[1. Pi 10^-3, 1, 5]

"3.141592653589793*^6"

"0.0031415926535897933`"

"3.1416*^6"

"0.0031416"

This function might be very useful when exporting lots of numbers to a human-readible file format (see also this post).

$\endgroup$
13
$\begingroup$

The second argument controls whether to add NumberMarks

Internal`DoubleToString[1. Pi 10^6, True, 5]

(* "3.1416`*^6" *)

Internal`DoubleToString[1. Pi 10^6, False, 5]

(* "3.1416*^6" *)

Note that anything different from an explicit True or False will use the Automatic setting.

$\endgroup$
  • $\begingroup$ Ah, very good. Thank you, ilian! $\endgroup$ – Henrik Schumacher Apr 11 '18 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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