Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider this code:

ScientificForm[1., 8, NumberFormat -> (Row[If[#3 == "", {#1, "E", 0}, {#1, "E", #3}]] &)]
(* 1.E0 *)

ToString@ScientificForm[1., 8, NumberFormat -> (Row[If[#3 == "", {#1, "E", 0}, {#1, "E", #3}]] &)]
(* 1.E0E0 *)

Why is there an extra "E0" in the second output?

share|improve this question
    
Use {#1, "E", "0"} instead of {#1, "E", 0}. –  Silvia Dec 10 '13 at 4:15
add comment

1 Answer

up vote 3 down vote accepted

I think you should use {#1, "E", "0"} instead of {#1, "E", 0}, or you can use ToString[#, StandardForm] &. But the former one is safer I think, cause I noticed a parameter other than integer will crash the kernel on my 9.0.1:

ScientificForm[1., 8, 
  NumberFormat -> (Row[
      If[#3 == "", {#1, "E", 1.2}, {#1, "E", #3}]] &)] // ToString
share|improve this answer
    
Thanks:) Do you know why ToString adds the extra "E0"? –  xslittlegrass Dec 10 '13 at 6:27
    
@xslittlegrass I'm not sure. But ToString uses OutputForm by default, so this really is not about ToString, but about formatting. Maybe checking the underlying boxes will reveal some detail. –  Silvia Dec 10 '13 at 7:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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