Decimal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gpappas
    New Member
    • Oct 2008
    • 1

    Decimal

    I want to see if a number is decimal what is the way to do it?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Do you mean float?
    [code=Python]>>> num = 1.2345
    >>> isinstance(num, float)
    True
    >>> [/code]

    Comment

    • kudos
      Recognized Expert New Member
      • Jul 2006
      • 127

      #3
      I guess you could do the following test:

      Code:
      a = 1.23
      if(a%1 == 0):
       print "integer"
      else:
       print "float"
      Would ofcourse fail for 1.0 etc, but then I guess it doesn't matter if its float

      -kudos

      Comment

      Working...