spacer
Yehuda Shiran September 9, 2000
Trimming Decimal Numbers
Tips: September 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Linux Subscriptions Paying Off for Red Hat
OpenVAS Charts Its Own Forked Course
A Linux Year in Review: Sun's Very Big Buy
Until IE5.5, formatting numbers was a real challenge. We all used high mathematical functions such as Math.ceil and Math.pow to format numbers the way we wanted to. IE5.5 fixes this problem with three new methods of the Number prototype object:

  • toFixed(fractionDigits)
  • toExponential(fractionDigits)
  • toPrecision(precision)
The toFixed(fractionDigits) method formats a number with fractionDigits digits after the decimal place. If, for example,

x = 2.345678904557788;
and you call alert(x.toFixed(3)), you'll get 2.346 in IE5.5 .

Learn more about formatting in Internet Explorer 5.5 in Column 59, IE 5.5: Formatting, URIs, and Stack Operations.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Email Marketing Terms to Know · Search Engines 101: Paid Vs. Natural Search · Web 2.0 Tools
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Connecticut Town Lays Groundwork for Merged School, Municipal VoIP Network · Case Study: Leveraging Next-Gen Wi-Fi to Transform Healthcare · Tripp Lite Announces Five New Surge Suppressors