Currency Decimal Places

Gene--O

07-01-2013

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

Accepted Solutions (1)

Accepted Solutions (1)

Answers (5)

Answers (5)

Kosta_Prokopiu

24-07-2020

🙂 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

 

Anilr1717

24-07-2020

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

Gene--O

08-01-2013

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

Gene--O

08-01-2013

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

radzmar

MVP

07-01-2013

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