Easy NumberFormat Question

2004-11-24 Thread Peterson, Andrew S.
Hello,
 
Is there a number formatting function that will show a maximum of two
decimal places when a remainder exists and no decimal places if it
doesn't exist? Right now I'm using numberformat and it's showing two
decimal places when there is no remainder. I'd just like for those cases
to show up as X, not X.00.
 
The last time I did something like this, I did an if statement to check
for the remainder and formatted correspondingly. I think that was CF 5.
Does a function exist for this? 
 
Thanks in advance!
 
Sincerely,
 
Andrew


~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185299
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Easy NumberFormat Question

2004-11-24 Thread James Smith
You can use...

cfset myNumber = round(myNumber * 100)/100

To get you desired formatting. 

--
Jay

 -Original Message-
 From: Peterson, Andrew S. [mailto:[EMAIL PROTECTED] 
 Sent: 24 November 2004 15:20
 To: CF-Talk
 Subject: Easy NumberFormat Question
 
 Hello,
  
 Is there a number formatting function that will show a 
 maximum of two decimal places when a remainder exists and no 
 decimal places if it doesn't exist? Right now I'm using 
 numberformat and it's showing two decimal places when there 
 is no remainder. I'd just like for those cases to show up as 
 X, not X.00.
  
 The last time I did something like this, I did an if 
 statement to check for the remainder and formatted 
 correspondingly. I think that was CF 5.
 Does a function exist for this? 
  
 Thanks in advance!
  
 Sincerely,
  
 Andrew
 
 
 

~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185302
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Easy NumberFormat Question

2004-11-24 Thread S . Isaac Dealey
Sierra Bufe submitted this udf to cflib.org:

function RoundIt(num,digits) {
var i = num;
// multiply by 10 to the power of the number of digits to be
preserved
i = i * (10 ^ digits);
// round off to an integer
i = Round(i);
// divide by 10 to the power of the number of digits to be preserved
i = i / (10 ^ digits);
// return the result
return i;
}


cfoutput
div#roundit(10,2)#/div
div#roundit(10.258,2)#/div
/cfoutput

seems to do what you want.

Also seems consistent with James' answer to your question.

 Hello,

 Is there a number formatting function that will show a
 maximum of two
 decimal places when a remainder exists and no decimal
 places if it
 doesn't exist? Right now I'm using numberformat and it's
 showing two
 decimal places when there is no remainder. I'd just like
 for those cases
 to show up as X, not X.00.

 The last time I did something like this, I did an if
 statement to check
 for the remainder and formatted correspondingly. I think
 that was CF 5.
 Does a function exist for this?

 Thanks in advance!

 Sincerely,

 Andrew


 

~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185312
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Easy NumberFormat Question

2004-11-24 Thread Peterson, Andrew S.
Thanks guys. I checked cflib but missed this. 
 
Sincerely,
 
Andrew

-Original Message-
From: S. Isaac Dealey [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 24, 2004 10:24 AM
To: CF-Talk
Subject: Re: Easy NumberFormat Question

Sierra Bufe submitted this udf to cflib.org:

function RoundIt(num,digits) {
var i = num;
// multiply by 10 to the power of the number of digits to be
preserved
i = i * (10 ^ digits);
// round off to an integer
i = Round(i);
// divide by 10 to the power of the number of digits to be
preserved
i = i / (10 ^ digits);
// return the result
return i;
}


cfoutput
div#roundit(10,2)#/div
div#roundit(10.258,2)#/div
/cfoutput

seems to do what you want.

Also seems consistent with James' answer to your question.

 Hello,

 Is there a number formatting function that will show a maximum of two 
 decimal places when a remainder exists and no decimal places if it 
 doesn't exist? Right now I'm using numberformat and it's showing two 
 decimal places when there is no remainder. I'd just like for those 
 cases to show up as X, not X.00.

 The last time I did something like this, I did an if statement to 
 check for the remainder and formatted correspondingly. I think that 
 was CF 5.
 Does a function exist for this?

 Thanks in advance!

 Sincerely,

 Andrew


 



~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185318
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Easy NumberFormat Question

2004-11-24 Thread S . Isaac Dealey
 Thanks guys. I checked cflib but missed this.

 Sincerely,

 Andrew

Welcome. It was something I'd seen in the code recently at my 9-5 job,
otherwise I likely wouldn't have been able to offer the suggestion. :)

s. isaac dealey   954.927.5117

new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework
http://www.sys-con.com/story/?storyid=44477DE=1
http://www.sys-con.com/story/?storyid=45569DE=1
http://www.fusiontap.com




~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185359
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54