Skip to main content
13-Aquamarine
September 10, 2025
Question

RTOS Round to 1 decimal or 0

  • September 10, 2025
  • 2 replies
  • 311 views

No question but a tip. 

I want to have the dimensions of a bush in the parameter Subtitle
If a dimension is rounds to zero, then I don't want that zero in the Parameter subtitle.

Example:

di = 0.8

L = 2.5

D = 4

 

RTOS defaults to rounding to 1 decimal (RTOS is available from Creo 11 and higher)

If I would do it that way then it would be 

SUBTITLE = \
"d" + RTOS(Di)+\
" L" + RTOS(L)+\
" D" + RTOS(D)

Which would result in Subtitle == d0.8 L2.5 D4.0 


If I would type RTOS(D,0) then it would be "D4"
With that knowledge I made an equation for how much decimals I need.

Ceil(D - Floor (D))

In this case if D = 4,2 it would be 4,2-4 which is 0,2 and it is then rounded up to 1
If D = 4,0 then it would be 4,0 - 4 which is 0 and it is then rounded op to 0

So then you get

SUBTITLE = \
"d" + RTOS(Di,Ceil(Di - Floor (Di))) +\
" L" + RTOS(L,Ceil(L - Floor (L)))+\
" D" + RTOS(D,Ceil(D - Floor (D)))

Which would result in Subtitle == d0.8 L2.5 D4

But we are not there yet, because in edge cases where you have two decimals which are rounded down to 0 or rounded up to 1, it still goes wrong.
If D is 4.01 the string for D would be 4.0

So I used Floor on the values but added 0.05 so it would behave like a normal Round

SUBTITLE = \
"d" + RTOS(Di,Ceil(Floor(Di+0.05,1) - Floor (Di+0.05))) +\
" L" + RTOS(L,Ceil(Floor(L+0.05,1) - Floor (L+0.05) )) +\
" D" + RTOS(D,Ceil(Floor(D+0.05,1) - Floor (D+0.05) ))

 In this case even if D = 3.99 or 4.01, it would result in Subtitle == d0.8 L2.5 D4

I hope this helps people.
And maybe someone has a version that is even better.

2 replies

13-Aquamarine
April 22, 2026

It also works with string_ends

SUBTITLE = \
"d" + if (string_ends (RTOS (Di,1), "0") , RTOS (Di,0), RTOS (Di,1)) + \
" L" + if (string_ends (RTOS (L,1), "0") , RTOS (L,0), RTOS (L,1)) + \
" D" + if (string_ends (RTOS (D,1), "0") , RTOS (D,0), RTOS (D,1))

 

21-Topaz II
April 22, 2026

The difficulty of dealing with floating point numbers is that sometimes the number you are dealing with has “extra baggage” in the decimal portion of the number. For example, you might input 5.0, but because of the way the number is stored, Creo stores it as 5.0000001.

Because of this, the calculation you make will yield not zero, the expected answer, but 1, because ceil ( 0.0000001 ) = 1

Perhaps a more reliable expression would be the somewhat more involved:

ceil ( floor ( 10 * ( D - floor ( D ) ) ) / 10 )

What I’m doing is shifting the number left a digit, chopping off all the digits to the right of the decimal, then shifting back to the right and getting the ceiling of the result.

Then again, if you’re only interested in the resultant strings, your second take on this is probably the best.