Skip to main content
12-Amethyst
January 10, 2023
Solved

Round up in relation/ program

  • January 10, 2023
  • 2 replies
  • 3188 views

Hello, 

I would like to know if it's possible to round up the number with the function CEIL / FLOOR at hundreds.

I only can round at the unity.

Exemple I have 5900/6 = 983.333...

I would like to set this value to 1000

thank you for reading.

 

 

Best answer by KenFarley

To do what you are describing you need to divide the number you are manipulating by 1000, get the ceil of that, then multiply the result by 1000.

For your example, this would read:

 

result = 1000 * ceil ( ( 5900 / 6 ) / 1000 )

 

If you are trying to actually "round" the value, i.e. any value between 500 and 999 yields 1000, numbers less than 500 are zero, you need to do something more like:

result = 1000 * floor ( ( 5900 / 6 ) / 1000 + 0.5 )

 

in the "ceil ( value, decimal )" command the "decimal" parameter is telling the function which decimal digit to "cut off" the result at. ceil ( 5.234, 2 ) means start at the second decimal place, so the result of ceil ( 5.234, 2 ) = 5.240. A negative "decimal" value is not valid.

 

2 replies

12-Amethyst
January 10, 2023

In the guide of PTC it is write that you can do round after the comma, " ceil (10.2)."

So i tried to do it with a negative number " attached"

But it doesnt work....

 

 

KenFarley
KenFarley21-Topaz IIAnswer
21-Topaz II
January 10, 2023

To do what you are describing you need to divide the number you are manipulating by 1000, get the ceil of that, then multiply the result by 1000.

For your example, this would read:

 

result = 1000 * ceil ( ( 5900 / 6 ) / 1000 )

 

If you are trying to actually "round" the value, i.e. any value between 500 and 999 yields 1000, numbers less than 500 are zero, you need to do something more like:

result = 1000 * floor ( ( 5900 / 6 ) / 1000 + 0.5 )

 

in the "ceil ( value, decimal )" command the "decimal" parameter is telling the function which decimal digit to "cut off" the result at. ceil ( 5.234, 2 ) means start at the second decimal place, so the result of ceil ( 5.234, 2 ) = 5.240. A negative "decimal" value is not valid.

 

12-Amethyst
January 10, 2023

Thank you for your answer ! 

I had the formula in mind  but tahnk you for remind me clearly! 

What I had in my mind by negative number was more like on Excel, when you put a négative number it goes up and round in the tens and hundreds value.

I'm new on the program and relation of CREO so maybe it was a stupid question...

 

 

 

KenFarley
21-Topaz II
January 11, 2023

Relations are kind of a unique thing. Weird that there's not a simple "round" function, so we're forced to do messy things like what I suggested.