Home > Archive > Java Help > March 2006 > java natural exponential and 'Infinity'
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
java natural exponential and 'Infinity'
|
|
| NoIdea 2006-03-22, 7:06 pm |
| how do you test for an infinite result given by the Java Math.exp()
function?
i need to do something like :-
if (Math.exp(200) "is infinite" ) {
{do something}
}
i've tried enclosing "Infinity" in quotes but it seems to think I'm
treating it as a string. Anyone any ideas how to do this?
Thanks
| |
| Thomas Weidenfeller 2006-03-22, 7:06 pm |
| NoIdea wrote:
> how do you test for an infinite result given by the Java Math.exp()
> function?
>
> i need to do something like :-
>
> if (Math.exp(200) "is infinite" ) {
> {do something}
> }
>
> i've tried enclosing "Infinity" in quotes but it seems to think I'm
> treating it as a string. Anyone any ideas how to do this?
Double.POSITIVE_INFINITY
Double.NEGATIVE_INFINITY
/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS...ng/java/gui/faq
http://www.uni-giessen.de/faq/archi...g.java.gui.faq/
| |
| Oliver Wong 2006-03-22, 7:06 pm |
|
"NoIdea" <foru@yahoo.com> wrote in message
news:QleUf.21660$Nh7.12352@newsfe4-win.ntli.net...
> how do you test for an infinite result given by the Java Math.exp()
> function?
>
> i need to do something like :-
>
> if (Math.exp(200) "is infinite" ) {
> {do something}
> }
>
> i've tried enclosing "Infinity" in quotes but it seems to think I'm
> treating it as a string. Anyone any ideas how to do this?
Thomas gave you the answer. I just wanted to clarify that whenever you
enclose something in double-quotes, Java will always treat that as a String.
If you enclose something in single-quotes, it will always be treated as a
char.
- Oliver
| |
| Patricia Shanahan 2006-03-22, 7:06 pm |
| NoIdea wrote:
> how do you test for an infinite result given by the Java Math.exp()
> function?
>
> i need to do something like :-
>
> if (Math.exp(200) "is infinite" ) {
> {do something}
> }
>
> i've tried enclosing "Infinity" in quotes but it seems to think I'm
> treating it as a string. Anyone any ideas how to do this?
>
>
> Thanks
>
>
if( Double.isInfinite(Math.exp(200)) )
Double has a lot of utility methods, so it is a good idea to check its
javadoc if you are stuck trying to do something about a double.
Patricia
| |
|
|
| Chris Smith 2006-03-22, 7:06 pm |
| Roedy Green <my_email_is_posted_on_my_website@munged.invalid> wrote:
> On Wed, 22 Mar 2006 15:49:04 GMT, "NoIdea" <foru@yahoo.com> wrote,
> quoted or indirectly quoted someone who said :
>
>
> see http://mindprod.com/jgloss/floatingpoint.html#NAN
> and
> http://mindprod.com/jgloss/gotchas.html#NAN
Since this came up recently, you may want to clarify on that page that
dividing by zero does not result in NaN, unless the numerator is also
zero. Generally, it results in an infinity of the appropriate sign.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
| |
| Roedy Green 2006-03-22, 7:06 pm |
| On Wed, 22 Mar 2006 13:24:44 -0700, Chris Smith <cdsmith@twu.net>
wrote, quoted or indirectly quoted someone who said :
>Since this came up recently, you may want to clarify on that page that
>dividing by zero does not result in NaN, unless the numerator is also
>zero. Generally, it results in an infinity of the appropriate sign.
done
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
|
|
|
|