Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hi,
I have a situation where I need to express a number to 8 decimal places in a drawing. I have created a parameter in the model as a string due to the number of digits in the raw number.
Unfortunately when attempting in the standard approach in the drawing [.8] does not work after the ¶meter, is there another syntax I need to use with this not being a real number?
The number is: 0.00654322641148869
I cannot enter the parameter as a real number due to the precision limitation on these values, hence using string.
Hopefully someone can guide me in the right direction.
Solved! Go to Solution.
To try something, I defined two parameters, "numRaw" a real number, and "numRounded" a STRING.
The following relations assigned the raw value and then used it to build a string to represent your desired result.
numraw = 0.00654322641148869
IF numraw < 1.0
numrounded = "0."
ELSE
numrounds = ITOS ( floor ( numraw ) ) + "."
ENDIF
numrounded = numrounded + EXTRACT ( ITOS ( 10^8* ( 1 + numraw - floor ( numraw ) ) ), 2, 8 )
The ITOS function does an inherent rounding when used, or you could add specific calculations to round the number in whatever explicit manner you wish.
Parameters might look like they aren't using enough precision, but it's more a matter of what they are showing, not what they are holding. It's kind of like when you enter a number in an Excel cell - it might look like 2.556, but the actual value stored is 2.555789762 or whatever. I'm not sure what the actual decimal place limitation in Creo is, but it's definitely more places than just 8.
Hi @IE_1 ,
Unfortunately, the [.#] notation for limiting the number of decimal digits is not recognized in a string type parameter
I think we need to use some additional relation functions like extract
extract(string, position, length)
for example:
test="0.1234567890123456789"
limit=extract(test,1,(search(test,".")+8))
this sets the parameter TEST to the string value, then extracts from that parameter, starting from character #1 through 8 more characters from the position of the "."
An example for removing the lead 0 for the same test parameter would be
limit=extract(test,search(test,"."),9)
Hope this helps!
Mike
Thanks Mike, in my drawing what would I be calling up? &............
I've worked it out, thanks
Would it be possible to add a rounding function to this do you think?
To try something, I defined two parameters, "numRaw" a real number, and "numRounded" a STRING.
The following relations assigned the raw value and then used it to build a string to represent your desired result.
numraw = 0.00654322641148869
IF numraw < 1.0
numrounded = "0."
ELSE
numrounds = ITOS ( floor ( numraw ) ) + "."
ENDIF
numrounded = numrounded + EXTRACT ( ITOS ( 10^8* ( 1 + numraw - floor ( numraw ) ) ), 2, 8 )
The ITOS function does an inherent rounding when used, or you could add specific calculations to round the number in whatever explicit manner you wish.
Parameters might look like they aren't using enough precision, but it's more a matter of what they are showing, not what they are holding. It's kind of like when you enter a number in an Excel cell - it might look like 2.556, but the actual value stored is 2.555789762 or whatever. I'm not sure what the actual decimal place limitation in Creo is, but it's definitely more places than just 8.
With Creo 11, there is a RTOS function that will make these conversions easier.
Yeah, I saw that, but we won't be using Creo 11 for a long time. Licensing shenanigans, I'm afraid.