Code Point
September 08, 2010, 08:15:29 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Geshi Sintax Hilighting Mod Installed. Tens of languages available.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Integer division  (Read 2497 times)
Dalton
Jr. Member
*

Karma: 0
Offline Offline

Posts: 3


« on: August 28, 2006, 06:13:12 PM »

Why 5 / 2 is 2 and not 2.5?

Code
>>> 5 / 2
2
Logged
Alter Lobo
Global Moderator
Jr. Member
*****

Karma: 10
Offline Offline

Posts: 65


« Reply #1 on: August 28, 2006, 07:08:55 PM »

Both operands are integer. If you want a floating point result one of the operands must be a float:

Code
>>> 5.0 / 2
2.5
>>> 5 / 2.0
2.5
>>> 5. / 2
2.5
 
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!