473,769 Members | 3,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1399
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
1788
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 <input> elements float outside of the table. What is the proper styling for my desired effect? TIA~ PJ
6
5347
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 (Firefox/1.0) is, well, not. I have a left menu div, and a right content div, float left, the width of which is auto. My intention is that the content should fill the space to the right of the menu. In IE putting a float right div in the...
0
1022
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 text-align : horizontal of its parent container. Therefore its impossible to center DIVs that you need to position horizontally. Therefore I cannot see any other way of doing this other than using tables. Is there a workaround? --
5
4866
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 types. First there is some inefficiency in calculations. And then you get data inflation and questionable dependencies - e.g. with pickle,ZODB,mpi's ... : 0.0...
2
12033
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
1245
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
8182
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 were to wrap around the float, even better, but that's not necessary. However, I'm continuously running into two issues: 1.) If I make my table 100%, it writes over the float: right for tables where the content text is long enough. 2.) If I...
1
5529
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 for `fl1' "Why there is no distinction between signed and unsigned float type in C++?" Thanks...
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10043
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.