English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-03-20 22:58:12 · 5 answers · asked by Anonymous in Computers & Internet Programming & Design

5 answers

above is correct
but u have to check also if all the caracters it has are numeric and that it doesnt contain any non-numeric caracters
so the thing u have to check is:
-all caracters are numeric (so it is a number)
and the moments all caracters are numeric then no floating point exist (thus u dont have to check the floating condition..)

2007-03-20 23:17:03 · answer #1 · answered by abd 5 · 0 0

it simple an integer is a number with no decimal , u can either check for the decimal (floating point)
If the number has a floating Point then it is not an integer
Simple using string functions like inStr() and mid()

2007-03-20 23:09:11 · answer #2 · answered by I.TPro 2 · 0 0

Just do this....

//let say the input is in String
public boolean is_integer( String num )
{
//try to convert to Integer, if it is successful, then it is an integer
try {
int temp = Integer.parseInt( num );
System.out.println( num + " is an Integer!" );
return true;
} catch( NumberFormatException e)
{
System.out.println( " It is not Integer" );
return false;
}
}

/** OR **/

// Let say you are evaluating a String object
public boolean is_integer( )
{
//try to convert to Integer, if it is successful, then it is an integer
try {
int temp = Integer.parseInt( this );
System.out.println( temp + " is an Integer!" );
return true;
} catch( NumberFormatException e)
{
System.out.println( " It is not Integer" );
return false;
}
}

2007-03-20 23:35:16 · answer #3 · answered by Liviawarty J 2 · 0 0

too vague, need more info about function inputs, outputs, pre-conditions, post-conditions, etc. I can't read your mind.

2007-03-20 23:16:33 · answer #4 · answered by icnintel 4 · 0 0

I think this is a php-question.
So you should use php.net.

2007-03-21 01:43:51 · answer #5 · answered by Anonymous · 0 0

fedest.com, questions and answers