Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Currency Decimal Places

Gene--O
Level 4
Level 4

HELP!

I have ready many posts on this subject, and can't figure out why mine won't work - it seems so simple:

I have NumericField1 and NumericField2. I want to multipy the user entered value from NumericField1 by a fixed value (in this case .555) to return a currency rounded up to the nearest cent (hundredths decimal point). I have tried using the field pattern options, but NONE of them will round up, they just return a dollar value with 2 decimal places.

For example:

I enter "307" into NumericField1. This value multiplied by .555 returns $170.385. I want this to display as $170.39, but all I can get is $170.38.

Any help is appreciated!!!

Gene-O

1 Accepted Solution
Francis_Manly-E
Correct answer by
Level 2
Level 2

Hi Gene,

You could also use FormCalc's Round function:

$.rawValue = Round(NumericField1.rawValue *.555, 2);

Additional information on the Round function can be found here:

http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm?content=001462.html

View solution in original post

6 Replies
radzmar
Level 10
Level 10

Hi,

the decimal places are rounded by IEEE 754 standard.

See example 25.4 under the following link.

http://partners.adobe.com/public/developer/en/xml/xfa_spec_3_3.pdf#page=1056

You might overcome this by adding 0.001 to your result.

Such as

NumericField * .555 + 0.001

Gene--O
Level 4
Level 4

Thanks for your reply!

However, I cannot download the sample. I get a message that says the file is damaged and cannot be downloaded.

Any other suggestions??

Gene-O

Francis_Manly-E
Correct answer by
Level 2
Level 2

Hi Gene,

You could also use FormCalc's Round function:

$.rawValue = Round(NumericField1.rawValue *.555, 2);

Additional information on the Round function can be found here:

http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm?content=001462.html

View solution in original post

Gene--O
Level 4
Level 4

thank you thank you thank you thank you Francis!

I tried (in vain) to get the round function to work before. You're answer was correct!

have a wonderful day!

Gene-O

Anilr1717
Level 1
Level 1

Hi,

 

Just posting here so anybody can use it. 12345/1000 = 12.34 not 12.35

 

Code: 12.34

 

Floor(ToDouble(@CONTENT4)/1000)+'.'
+Substring( Iif(Length(ToString(Mod(ToDouble(@CONTENT4), 1000)))<=1,LPad(ToString(Mod(ToDouble(@CONTENT4), 1000)),3 ,'00' ),
Iif(Length(ToString(Mod(ToDouble(@CONTENT4), 1000)))=2,LPad(ToString(Mod(ToDouble(@CONTENT4), 1000)),3 ,'0' ),
ToString(Mod(ToDouble(@CONTENT4), 1000)))),1,2 )

 

Code: 12.35

 

Round(ToDouble(12345)/1000,2)

 

Regards,

Anil

Kosta_Prokopiu
Level 4
Level 4

🙂 I think there is an easier solution

 

12345/1000 on next lower cent: Math.floor(100*(12345/1000))/100   =>> 12.34

12345/1000 on next higher cent: Math.ceil(100*(12345/1000))/100 =>> 12.35