31 Replies Latest reply: Jul 12, 2014 7:11 AM by BKBK RSS

    Custom number format function does not work to return 0's as decimals

    genadi_mak

      Hi

      My custom number formatting function does not work. It was working fine when the site had a standard client server architecture. However, when we changed to using REST API with javascript and HTML5 the function works for most parts except cases when I need it to display 0's for decimals.

      Basically, the function takes arguments a number and number of decimals and, returns the number rounded to the number of decimals passed. Below, I stripped the function to bare minimum, same as I was testing.

       

      <cffunction name="dispCostPeriod" access="remote" returntype="string" output="false" hint="Displays costs for a given period to user">

           <cfargument name="in_decCost" type="numeric" required="yes" />

           <cfargument name="in_iRound" type="numeric" required="yes" />

        

           <cfset decRoundedNum = NumberFormat(in_decCost, "_." & RepeatString("9",in_iRound))>

           <cfreturn decRoundedNum />

      </cffunction>

       

      When I pass 55.00089 and 3, the function returns 55.001.

      When I pass 55 or 55.000000 or 55.0000089 and 3, the function returns 55. And, I need 55.000.

      I tried both to returntype "string" and "numeric", various masks like _.999, _.000, _.___.

      I tried straight return NumberFormat(in_decCost,"_.000").

      Nothing works.

      I am using CF10 on Windows Server 2008.

      Any help greatly appreciated.

      Thanks,

      Gena