4
$\begingroup$

How can I convert the number -0.000007 to a string -0.000007?

I tried:

x = -0.000007;
ToString[x]

That gives an exponential output.

ToString[AccountingForm[N[x, 10], {10, 6}]]

gives the value without sign and parentheses around

(0.000007)
$\endgroup$
4
$\begingroup$
x = -0.000007;

str = ToString @ AccountingForm[x, {12, 10}, NumberSigns -> {"-", ""}];

str // FullForm

"-0.000007"

ToExpression[str] + 1

0.999993

$\endgroup$
  • $\begingroup$ Thank you for the solution. When I evaluate str // FullForm I get: AccountingForm[-7.`*^-6,List[12,6],Rule[NumberSigns,List["-",""]]] $\endgroup$ – lio Jul 14 '17 at 15:52
  • $\begingroup$ I made a copy mistake, see updated answer with ToString $\endgroup$ – eldo Jul 14 '17 at 15:58

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.