0
$\begingroup$

2nd Code Block demonstrates failure in comment of output

    {x,y,z}=GeoPositionXYZ[OneWeb-0452]["XYZ"]; Print["Current Postion of OneWeb-0452 is(x=",SetPrecision[x,2],", y=",SetPrecision[y,2], ", z=",SetPrecision[z,2 ]," meters from the Center of the Earth"]
(* Current Position of OneWeb-0452 is(x=3.1*10^6, y=5.8*10^6, z=2.4*10^6 meters from the Center of the Earth*)

(* versus *)

Print["Current Position of OneWeb-0452 is(x=", 
 ToString[SetPrecision[x, 2]], ", y=", SetPrecision[y, 2], ", z=", 
 SetPrecision[z, 2 ], " meters from the Center of the Earth"]

(* Current Positiion of OneWeb-0452 is(x=      6
3.1 10, y=5.8*10^6, z=2.4*10^6 meters from the Center of the Earth*)
$\endgroup$
4
  • 1
    $\begingroup$ Try ToString[SetPrecision[x, 2], InputForm]. See the first examples here. $\endgroup$
    – Greg Hurst
    Commented Jul 16, 2022 at 21:19
  • $\begingroup$ Re-expands to Machine Precision so not the desired result. However, "TraditionalForm" did the trick! $\endgroup$ Commented Jul 16, 2022 at 21:34
  • $\begingroup$ Your code doesn't work for me. I'm not sure what the input to SetPrecision is. I also wonder about the title: SetPrecision[x, 1.2] does not appear in your code. $\endgroup$
    – Michael E2
    Commented Jul 16, 2022 at 21:37
  • 3
    $\begingroup$ Are you looking for NumberForm rather than SetPrecision? $\endgroup$
    – JimB
    Commented Jul 16, 2022 at 21:41

1 Answer 1

1
$\begingroup$

Try ToString[SetPrecision[x, 2], TraditionalForm]

$\endgroup$

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.