Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I hide third place decimal when it's zero?

New Here ,
May 08, 2019 May 08, 2019

For example. There are occasions when I need the number to say $60,000.125. But another line might cost $12,000.670 But I want it to read $12,000.67 when the third place is zero. Any thoughts? Please help!

Thank you!

TOPICS
PDF forms
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2019 May 08, 2019

Is this a calculated value? If so, what code are you using for it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 08, 2019 May 08, 2019

Screen Shot 2019-05-08 at 11.37.30 AM.png

This is what I have. I'm just using the regular formatting when creating a form. Qty x Unit price = Amount

Looking for when the third decimal is zero, to be hidden if possible. Does that make sense?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2019 May 08, 2019

You'll have to use a custom Format script to be able to do it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 08, 2019 May 08, 2019

Where can I find information on a custom format script? I'm new to this. Sorry!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2019 May 08, 2019

Here's an article:

https://acrobatusers.com/tutorials/formatting_text_fields

In your case you'll need to use the "util.printf()" function.

Here's the reference entry

Acrobat DC SDK Documentation

You'll want to use the float formating options something like

event.value = util.printf("%0.2f",event.value);

You may need extra code to detect non-number field values.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 08, 2019 May 08, 2019

It may sound a bit esoteric, but there is actually a difference between 1.230 and 1.23.

In the first case, the precision is ensured to be 3 digits, whereas in the second case, it is 2 digits. For common uses, this does not make much of a difference, but if you have to ensure the precision over the whole process, it does matter.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2019 May 09, 2019
LATEST

Calculating with money needs a special discipline, otherwise auditors and lawyers will be upset.

Consider this purchase

ITEM 1      1.124

ITEM 2      1.124

ITEM 3      1.124

TOTAL       3.372

Ok, let's round these to the nearest cent on each line

ITEM 1      1.12

ITEM 2      1.12

ITEM 3      1.12

TOTAL       3.37

However, anyone can see this no longer adds up. This is inviting legal action, or a complete loss of cusomer confidence.  You actually have to really round each line item's price, not just show less digits on the page

ITEM 1      1.12

ITEM 2      1.12

ITEM 3      1.12

TOTAL       3.36

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines