Productive Computing, Inc. Support Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

SMF - Just Installed!

Pages: [1]   Go Down

Author Topic: Bug in FormatCurrency Custom Function?  (Read 1703 times)

mcspencer

  • Member
  • *
  • Posts: 6
Bug in FormatCurrency Custom Function?
« on: November 05, 2013, 07:53:51 AM »

The way the FormatCurrency CF is currently written is causing unexpected behavior when dealing with negative numbers that are less than 1.

The "Prevent Negative Zero" portion causes the amount to flip from a negative to a positive because wholePart = 0

Code: [Select]
    //prevent negative zeroes
    signPrefix = Case ( wholePart = 0 ; "" ; signPrefix )

If you change it to this:

Code: [Select]
    //prevent negative zeroes
    signPrefix = Case ( wholePart = 0 and decimalPart = 0; "" ; signPrefix )

It will then still prevent negative zeroes but still allow for negative amounts less than 1.

As currently coded:



With new code:
Logged
Pages: [1]   Go Up