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

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

New Here ,
May 08, 2019 May 08, 2019

Copy link to clipboard

Copied

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

Views

965

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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