Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 7th, 2008, 02:56 PM
Newbie
 
Join Date: Oct 2008
Posts: 1
Default Decimal

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

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

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
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles