Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Truncating floating point values
- From: javascript@xxxxxxxxxx (Mckinney, Lori K)
- Subject: [Javascript] Truncating floating point values
- Date: Thu, 28 Mar 2002 10:49:17 -0600
Cutter,
Can you do something like this?
function fixAtTwo(anynum)
{
var numStr=anynum.toString();
var decPos = numStr.indexOf(".");
if ( decPos == -1 )
return numStr + ".00";
else
{
// add two zeros to get at least two digits at the
// end of the string in case it ends at the decimal
numStr += "00";
return numStr.substr(0,decPos+3);
}
}
Hope that works for you.
Lori
P.S. By the way, hope your little girl is doing well.
-----Original Message-----
From: Cutter Bl [mailto:cutterbl@xxxxxxxxxxx]
Sent: Thursday, March 28, 2002 10:27 AM
To: Javascript@xxxxxxxxxx
Subject: [Javascript] Truncating floating point values
How do you truncate a floating point value at a specific decimal place? I'm
not trying to round the number, just cut it off after two decimal places...
Cutter
http://www.falcon-knives.com
_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com
_______________________________________________
Javascript mailing list
Javascript@xxxxxxxxxx
https://lists.LaTech.edu/mailman/listinfo/javascript
- Prev by Date: [Javascript] Q on wondow.focus()
- Next by Date: [Javascript] Stupid Q on FORMS & TARGET
- Previous by thread: [Javascript] Truncating floating point values
- Next by thread: [Javascript] Stupid Q on FORMS & TARGET
- Index(es):