These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Decimal Field Display Pattern

svsatishkumar
Registered: Nov 21 2007
Posts: 25

Hi,

I have a Decimal Field whose Interger length is 23 and Decimal Length 2.
when i give some input it should not add zero before the Interger part.
I tried by giving a Display Pattern of the format
ZZZZZZZZZZZZZZZZZZZZZZ9.99.

Up to 16 digits(Interger part) the value is formated correctly.
when the length crosses 16 it is showing some other number

say for the input 1234567890123456 output is 1234567890123456.00
12345678901234567 output is 12345678901234566
12345678901234569 output is 12345678901234568

what is the reason for this.why that is not displaying the correct value.

pddesigner
Registered: Jul 9 2006
Posts: 858
Formatting a number in a form field
This tip works in Acrobat and has not been converted to work with LiveCycle.

Shows how to format numbers in decimal, hex, and floating formats as well as formatting the value as a string.
You can cut-and-paste the following script into the JavaScript console, select the script, and press Enter. The resulting formatting is shown below under “Output.” (The “Math.PI” expression is a JavaScript constant equal to the value of π).

var n = Math.PI * 100;

// Decimal format:
console.println(util.printf("Decimal format:
%d", n));

// Hex format:
console.println(util.printf("Hex format: %x",
n));

// Floating point format:
console.println(util.printf("Float format:
%.2f", n));

// String format:
console.println(util.printf("String format:
%s", n));


Output:
Decimal format: 314
Hex format: 13A
Float format: 314.16
String format: 314.159265358979
Formatting: removing zeros so field is blank

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
FormCalc automatically rounds numbers with more than 16 digits, because larger numbers are not supported.

From the specs:

All number literals are internally converted to [IEEE754] 64-bit binary values. However, IEEE 754 values can only represent a finite quantity of numbers. Just as some numbers, such as 1/3, are not representable precisely as decimal fractions, other numbers are not precisely representable as binary fractions. Specifically, but not limited to, number literals having more than 16 significant digits in the non-exponent part will be the rounded to the nearest representable IEEE 754 64-bit value using a round-to-nearest mechanism. This means that a number literal like 123456789.012345678 will be rounded to the (nearest) value 123456789.01234567 and a number literal like 99999999999999999 will be rounded to the (nearest) value 100000000000000000 This behaviour is conformant to the IEEE 754 standard.
This behaviour can sometimes lead to surprising results. FormCalc provides a function, Round(), which returns a given number rounded to a given number of decimal places. When the given number is exactly halfway between two representable numbers, it is rounded away from zero; up if positive, and down if negative. So, e.g., round(.124, 2) returns 0.12, and round(.125, 2) returns 0.13. Given this convention, one might expect then that round(0.045, 2) returns 0.05. It doesn't. IEEE 754 dictates that the number literal 0.045 be approximated to 0.0449999999999999 This approximation is closer to 0.04 than to 0.05, so Round(0.045, 2) returns 0.04. This too is conformant to the IEEE 754 standard.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs