Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
YogeshM #1
Format a number to any decimal places
Hi! I'm having a small problem to format a number to some decimal places and
I'd be glad if someone could please help me solve this issue. e.g. I have 2
numbers number_1 = 100.0052 number_2 = 100.005165665 I need to format
number_2 to the same number of decimal places as number_1, bearing in mind that
number_1 could have 3,4,5 or any number of decimal places. Any idea how to do
this please? This is what I have already done: 1. Get the position of the
decimal place <cfset start = #findNoCase('.',number_1,1)#> 2. Get the number
of decimal places in number_1 <cfset dp = #len(mid(number_1,start +
1,len(number_1)))#> If I <cfouput>No. of decimal places = #dp#</cfoutput>, it
returns 3, 4, 5 etc, depending on the no. of decimal places in number_1 Now
how can i format number_2 to #dp# decimal places? Thanks and regards, Yogesh
Mahadnac.
YogeshM Guest
-
Max number of decimal places in cfprocparam?
It appears that the maximum number of decimal places that cfprocparam will return is 12, using this syntax: <cfprocparam type="Out"... -
To 2 decimal places
Folks, I know some of you here are extremely dynamic. I am working with a variable that is declared as a decimal. But I want to convert the... -
Limited the number of decimal places returned?
I've moved on from functions for the time being, and was playing with do some maths and date/time manipulation. Lets say I wanted to show the... -
Decimal places!
Hi fellow Director users!, I had a countdown timer (75 seconds) for a game, and I wanted to display the time taken to complete it, in a field. ... -
do not cut decimal places
Hi, following problem (oracle8): I want to insert a value with precision (#.##) in a number(10,2) column. It works but the values which end with... -
MikerRoo #2
Re: Format a number to any decimal places
<cfouput>
#NumberFormat (number_2, '0.#RepeatString ('0', dp)#')#
</cfouput>
MikerRoo Guest
-
OldCFer #3
Re: Format a number to any decimal places
An easier way to get dp:
<cfset dp = Len(ListLast(number_1,"."))>
OldCFer Guest
-
-



Reply With Quote

