Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] (no subject)
- From: linuxgold at gmail.com (Scott Hamm)
- Subject: [Javascript] (no subject)
- Date: Wed Nov 2 12:25:46 2005
I only care for Decimal(4,2) -- for SQL data type.
On 11/2/05, Mark Wonsil <wonsil@xxxxxxxxxx> wrote:
> >
> > kpp = parseFloat(kpp);
> > kph = parseFloat(kph);
> > if(!isNaN(kpp) &&!isNaN(kph) )
> > {
> > ktot = kpp + kph;
> > }
> > alert("passed here, with value of " + ktot + ".")
> > If(ktot>'8')
>
> It's a type issue, very common in JavaScript. Ktot is a float but '8' is a
> character. Try:
>
> If (ktot > 8f)
>
> Or
>
> If (ktot > parseFloat('8'))
>
> BTW, comparing floats can be tricky. Do you care if the total is 8.00001 or
> 8.000000003232? Those will be greater than 8.0. What I normally do is
> subtract the two numbers, take the absolute value and check to see if the
> difference is within my tolerance:
>
> If (abs(ktot - 8.0f)) < 0.0001
>
> Mark W.
>
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
--
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
- Follow-Ups:
- [Javascript] Attachments
- From: Innerlab
- [Javascript] Attachments
- References:
- [Javascript] (no subject)
- From: Scott Hamm
- [Javascript] (no subject)
- From: Mark Wonsil
- [Javascript] (no subject)
- Prev by Date: [Javascript] (no subject)
- Next by Date: [Javascript] (no subject)
- Previous by thread: [Javascript] (no subject)
- Next by thread: [Javascript] Attachments
- Index(es):