# Number picture to clip trailing zeros in a decimal number

**URL:** <https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312>\
**Category:** tips\
**Created:** [July 29, 2022, 10:00am UTC](https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312 "2022-07-29T10:00:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bostjan\_Laba](https://clarionhub.com/user_avatar/clarionhub.com/bostjan_laba/32/2498_2.png) [@Bostjan\_Laba](https://clarionhub.com/u/Bostjan_Laba)\
**Post date:** [July 29, 2022, 10:00am UTC](https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312/1 "2022-07-29T10:00:11Z")

</div>

Don’t ask why, I just need to figure out a way for a number picture which would clip off zeros.  
So 198,80 should become 198,8  
If 198,65 it’s left as it is. and 198,00 become 198 of course  
Note that my decimal separator is comma, not dot.

So user can enter any integer or decimal number (with max 2 decimal places) but I need to reformat it as above. Entry picture is N-10.`2

Any idea without bunch of IF sentences?

Thanks

Bostjan

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 29, 2022, 9:25pm UTC](https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312/2 "2022-07-29T21:25:29Z")

</div>

Pretty simple loop backwards in a function. Don’t think there’s a picture for this.

---

<div class="post-metadata">

**Author:** ![RichCPT](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/e19b73/32.png) [@RichCPT](https://clarionhub.com/u/RichCPT)\
**Post date:** [July 29, 2022, 10:00pm UTC](https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312/3 "2022-07-29T22:00:23Z")

</div>

How about assigning the decimal variable to a string and display the resulting string. I think that is how I have clipped the trailing decimal zeros in the past. If you are dealing with the issue on-screen for a data entry field then perhaps use a STRING variable for input with a KEY-IN template instead of a PICTURE.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 30, 2022, 1:09am UTC](https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312/4 "2022-07-30T01:09:45Z")

</div>

The commas tripped me up, despite Bostjan’s warning.  
As long as you’re talking only about the right side of the “decimal”, I’ve done exactly what you’ve suggested, in the past.

---

<div class="post-metadata">

**Author:** ![Bostjan\_Laba](https://clarionhub.com/user_avatar/clarionhub.com/bostjan_laba/32/2498_2.png) [@Bostjan\_Laba](https://clarionhub.com/u/Bostjan_Laba)\
**Post date:** [July 30, 2022, 2:54pm UTC](https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312/5 "2022-07-30T14:54:19Z")

</div>

I ended up without formatting the output value. So user still has @n-10.`2 but I deal with the number unformatted. Only thing I do is use Stringtheory to replace dot with comma. The rest works by itself actually.

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [July 31, 2022, 5:01am UTC](https://clarionhub.com/t/number-picture-to-clip-trailing-zeros-in-a-decimal-number/5312/6 "2022-07-31T05:01:27Z")

</div>

sounds like you have it sorted Bostjan.

But for future reference, seeing you mentioned StringTheory I probably should add that the st.trim method allows you to specify an “alphabet” - a list of characters to remove from the start and end of a string.

st.trim(‘0\<32\>’) ! remove spaces and zeroes from beginning and end of string

[https://www.capesoft.com/docs/StringTheory3/StringTheory.htm#Trim](https://www.capesoft.com/docs/StringTheory3/StringTheory.htm#Trim)

if you use it without a parameter it just gets rid of spaces

cheers

Geoff R
