Bug introduced in 10.1
I wrote a helper function to format real numbers in a certain format for writing .dbf files here. It relies on a new function to 10.1 - StringPadLeft
.
Here's that function:
realformat[num_] := ToString@ScientificForm@PaddedForm[num + 0., {12, 11},
NumberFormat -> (Row[{#1, "e", If[ToExpression[(#3 /. "" -> "0")] < 0, "-", "+"],
StringPadLeft[StringReplace[ToString@#3, "-" -> ""], 3, "0"]}] &)]
SetAttributes[realformat, Listable]
realformat[{56023.3, 16, -1523532.1}]
{" 5.60233000000e+004", " 1.60000000000e+001", "-1.52353210000e+006"}
However, the first time this is called (ie on a fresh kernel), I get the following error:
Get::noopen: Cannot open C:\Users\username\AppData\Roaming\Mathematica\Paclets\Repository\GeneralUtilities-10.2.1\Kernel\ 64.00000000000Bit\GeneralUtilities.mx\
And the output is as such:
{" 5.60233000000e+StringPadLeft[4, 3.00000000000e+StringPadLeft[, \ 3.00000000000, 0], 0]", " 1.60000000000e+StringPadLeft[1, \ 3.00000000000e+StringPadLeft[, 3.00000000000, 0], 0]", \ "-1.52353210000e+StringPadLeft[6, 3.00000000000e+StringPadLeft[, \ 3.00000000000, 0], 0]"}
Oh dear.
Now I can navigate to the folder C:\Users\username\AppData\Roaming\Mathematica\Paclets\Repository\GeneralUtilities-10.2.1
and manually run the GeneralUtilities package, which solves the issue, but that's rather annoying. All file permissions look okay and I've tried resetting all settings to no avail.
Anybody have a solution or is this a bug?
$Version
10.2.0 for Microsoft Windows (64-bit) (July 7, 2015)
StringPadLeft;
before runningrealformat
which will trigger all necessary autoloading. $\endgroup$PaddedForm
temporarily overrides the default number formatting parameters (and restores them once it is done), but these non-default values are still in effect when theNumberFormat
option value is applied. For a simpler example, considerPaddedForm[1, {2, 3}, NumberFormat -> ((Print@ToString[4]; #1) &)]
where the printed form of 4 is getting padded. $\endgroup$