ldodgen Posted March 16, 2006 Share Posted March 16, 2006 I am adding two number together and want to be able to set the precision of my output to 2, so it looks like (12.00) and not (12). How can I do this? Help? Link to comment Share on other sites More sharing options...
vchris Posted March 16, 2006 Share Posted March 16, 2006 That's not done with HTML/XHTML more like Javascript or a server scripting language. Link to comment Share on other sites More sharing options...
scott100 Posted March 16, 2006 Share Posted March 16, 2006 use toFixed(), in your case varable.toFixed(2);see below: <script>var profits=2489;alert("before toFixed(): "+profits);profits=profits.toFixed(2);alert("after toFixed(): "+profits);</script> Link to comment Share on other sites More sharing options...
ldodgen Posted March 16, 2006 Author Share Posted March 16, 2006 use toFixed(), in your case varable.toFixed(2);Thanks for heading me in the right direction. now I just need to figure out how to use toFixed() in my situation. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 16, 2006 Share Posted March 16, 2006 what is your situation?If you post your code we can help you. Link to comment Share on other sites More sharing options...
ldodgen Posted March 16, 2006 Author Share Posted March 16, 2006 As it turns out I'm using XSLT to transform XML into HTML and XSLT has its own precision manipulator. I ended up using: <xsl:value-of select="format-number(12, '#.00;-#.00')"/> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now