473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

distinction between float & int

hi all,
can anyone tell me why this distinction? i mean why it returns False
on floats??
a = 1
b = 1
a is b True a = 1.1
b = 1.1
a is b False


thanx .
--
cheers,
Ishwor Gurung
Jul 18 '05 #1
1 1381
Ishwor wrote:
hi all,
can anyone tell me why this distinction? i mean why it returns False
on floats??
a = 1
b = 1
a is b
True
a = 1.1
b = 1.1
a is b
False
thanx .


There is no guarantee that this will hold in all implementations of Python.

The majority implementation, usually called CPython because its
implementation language is C, keeps copies of the first 100 (?) integers
so it doesn't have to create separate integer objects each time they are
required.

No caching at all is applied to floats, as far as I can tell.
a = 250
b = 250
a is b

False

regards
Steve

--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PJ | last post by:
http://www.paulwalker.tv/test.htm I want the Asset List title to float to the left in the cell and the <select> and <input> elements to float to the right. However, in Mac IE, the <select> and...
6
by: Jim Lawton | last post by:
I am trying to achieve a simple page layout using only divs and css. I know that people bad mouth IE for non-conformance, but in this case IE's(6.0)behaviour is entirely the way I expect, and Gecko...
0
by: McGeeky | last post by:
Hi. I am using DIVs for lay outs rather than tables but cannot resolve a catch 22. I need to use the float: left so that I can get DIVs to line up in rows however, float : left does not respect the...
5
by: robert | last post by:
Turning algs for old NumPy modules into numpy code I suffer from this: Upon further processing of returns of numpy calculations, lots of data in an apps object tree will become elementary numpy...
2
by: sbcaco | last post by:
Hello again... can someone tell me how to work around this error: String or binary data would be truncated. I am doing this: update table1 set =
0
by: liujiaping | last post by:
The code is as follows: 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 float a = 1.0f; 8 cout << (int)a << endl; 9 cout << (int&)a << endl;
2
by: shannona | last post by:
I've been banging my head against an interaction between a table and float element. I want the two of them to together take up 100% of the width of their container. If the table cells' content...
1
by: SchoolOfLife | last post by:
Hello, When I try compiling this code: signed float fl1=-10e-2; with variable declarations of type signed float and unsigned float, gcc 3.3.5 outputs: error: short, signed or unsigned invalid...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.