Connecting Tech Pros Worldwide Help | Site Map

Decimal

  #1  
Old October 7th, 2008, 02:56 PM
Newbie
 
Join Date: Oct 2008
Posts: 1
I want to see if a number is decimal what is the way to do it?
  #2  
Old October 7th, 2008, 04:29 PM
bvdet's Avatar
Moderator
 
Join Date: Oct 2006
Location: Nashville, TN
Posts: 1,545

re: Decimal


Do you mean float?
Expand|Select|Wrap|Line Numbers
  1. >>> num = 1.2345
  2. >>> isinstance(num, float)
  3. True
  4. >>> 
  #3  
Old October 9th, 2008, 09:18 AM
kudos's Avatar
Expert
 
Join Date: Jul 2006
Location: Norway
Posts: 106

re: Decimal


I guess you could do the following test:

Expand|Select|Wrap|Line Numbers
  1. a = 1.23
  2. if(a%1 == 0):
  3.  print "integer"
  4. else:
  5.  print "float"
  6.  
Would ofcourse fail for 1.0 etc, but then I guess it doesn't matter if its float

-kudos
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine which of the generic decimal datatypes to use. John Bentley answers 19 November 22nd, 2005 03:30 AM
(decimal) 1.1 versus 1.1M Paul Sullivan answers 10 November 17th, 2005 12:42 AM
Problem: DataRow alters stored System.Decimal values. Carl G answers 2 July 21st, 2005 04:48 PM
How to determine which of the generic decimal datatypes to use. John Bentley answers 17 July 21st, 2005 09:24 AM
prePEP: Decimal data type Batista, Facundo answers 21 July 18th, 2005 05:55 AM