Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
103
rated 0 times [  104] [ 1]  / answers: 1 / hits: 74375  / 14 Years ago, tue, january 18, 2011, 12:00:00

I have a series of Javascript calculations that (only under IE) show Infinity depending on user choices.



How does one stop the word Infinity appearing and for example, show 0.0 instead?


More From » infinity

 Answers
95
if (result == Number.POSITIVE_INFINITY || result == Number.NEGATIVE_INFINITY)
{
// ...
}


You could possibly use the isFinite function instead, depending on how you want to treat NaN. isFinite returns false if your number is POSITIVE_INFINITY, NEGATIVE_INFINITY or NaN.



if (isFinite(result))
{
// ...
}

[#94174] Monday, January 17, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jeniferjaliyahf

Total Points: 650
Total Questions: 104
Total Answers: 86

Location: Grenada
Member since Sun, Dec 20, 2020
4 Years ago
jeniferjaliyahf questions
Fri, Feb 11, 22, 00:00, 2 Years ago
Thu, Feb 10, 22, 00:00, 2 Years ago
Thu, Jun 17, 21, 00:00, 3 Years ago
Thu, Mar 25, 21, 00:00, 3 Years ago
Wed, Feb 17, 21, 00:00, 3 Years ago
;