Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Vivek Patel   on Aug 03 In Asp.net Category.

  
Question Answered By: Baylen Smith   on Aug 03

| | Does anyone know how to determine  if a given number  is an integer
| | without using string  functions?
|
| or if you're planning to use vb - you can just call the IsNumeric( )
| function

But IsNumeric will return true for both 3.14 and 3, while 3 is an
integer, but 3.14 is not.

One way to determine if a number is an Integer is to do something like:


If Convert.ToInt32(x) <> x then
'x is NOT an integer
Else
'Otherwise it is!
End If

This essentially truncates the value of x and then determines if the
truncated form equals the original form.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Math function to determine if a number is an int Or get search suggestion and latest updates.


Tagged: