Can I use NumToStr on a number with an exponent?
MikeTT
✭
Hi, I seem to be getting a Value error when attempting to use the NumToStr function on a num value with an exponent. Below is an example of my code, to give you an idea of what I am trying to do.
VAR robtarget currentPosition;
VAR num anglex;
currentPosition := CRobT(\Tool:=tool, \WObj:=workobject);
anglex := EulerZYX(\X, currentPosition.rot);
Write CalibrationLog,"Euler angle: X:" + NumToStr(angleX, 7);
The value inside angleX is -4.00217E-7, so I assume the fact that it is formatted this way is what is causing the value error in the NumToStr function. I tried using the Round function in hopes of getting rid of the exponent but this also throws a value error.
Does anyone have any ideas how I might be able to log this value?
VAR robtarget currentPosition;
VAR num anglex;
currentPosition := CRobT(\Tool:=tool, \WObj:=workobject);
anglex := EulerZYX(\X, currentPosition.rot);
Write CalibrationLog,"Euler angle: X:" + NumToStr(angleX, 7);
The value inside angleX is -4.00217E-7, so I assume the fact that it is formatted this way is what is causing the value error in the NumToStr function. I tried using the Round function in hopes of getting rid of the exponent but this also throws a value error.
Does anyone have any ideas how I might be able to log this value?
Tagged:
0
Best Answer
-
Use the optional argument \Exp. You might also try DNumToStr, but would still need that optional argument.Lee Justice0
Answers
-
Hi lemster,
I have tried using the \Exp argument but this does not seem to work either, my guess is that this is more about specifying that we want the output to formatted with an exponent, rather than accepting an input which is formatted this way.
Dnum did occur to me too, but the EulerZYX function returns a num, do you know how I can assign a num to a dnum variable?0 -
NumToDnum functionLee Justice0
-
Got it working with Dnum, thanks for the help!0
-
Great!Lee Justice0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings