Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [types]

Types, and type systems, are used to enforce levels of abstraction in programs.

1543 votes
17 answers
4.0m views

Change column type in pandas

I created a DataFrame from a list of lists: table = [ ['a', '1.2', '4.2' ], ['b', '70', '0.03'], ['x', '5', '0' ], ] df = pd.DataFrame(table) How do I convert the columns to ...
user avatar
1227 votes
9 answers
456k views

What are POD types in C++? [duplicate]

I've come across this term POD-type a few times. What does it mean?
oz10's user avatar
  • 157k
1925 votes
18 answers
1.6m views

What's the canonical way to check for type in Python?

How do I check if an object is of a given type, or if it inherits from a given type? How do I check if the object o is of type str? Beginners often wrongly expect the string to already be "a ...
Herge's user avatar
  • 21.8k
182 votes
2 answers
87k views

How does Python 2 compare objects of different types?

The following snippet is annotated with the output (as seen on ideone.com): print "100" < "2" # True print "5" > "9" # False print "100" < 2 # False print 100 < "2" ...
polygenelubricants's user avatar
207 votes
6 answers
134k views

Is char signed or unsigned by default?

In the book "Complete Reference of C" it is mentioned that char is by default unsigned. But I am trying to verify this with GCC as well as Visual Studio. It is taking it as signed by default. Which ...
C Learner's user avatar
  • 2,327
209 votes
20 answers
289k views

Immutable vs Mutable types

I'm confused on what an immutable type is. I know the float object is considered to be immutable, with this type of example from my book: class RoundFloat(float): def __new__(cls, val): ...
user1027217's user avatar
  • 2,261
7555 votes
68 answers
1.3m views

What is the difference between String and string in C#?

What are the differences between these two, and which one should I use? string s = "Hello world!"; String s = "Hello world!";
1131 votes
8 answers
275k views

What is the difference between old style and new style classes in Python?

What is the difference between old style and new style classes in Python? When should I use one or the other?
readonly's user avatar
  • 351k
1562 votes
8 answers
895k views

What are the differences between type() and isinstance()? [duplicate]

What are the differences between these two code snippets? Using type: import types if type(a) is types.DictType: do_something() if type(b) in types.StringTypes: do_something_else() Using ...
abbot's user avatar
  • 27.8k
87 votes
1 answer
8k views

What is the monomorphism restriction?

I'm puzzled by how the Haskell compiler sometimes infers types that are less polymorphic than what I'd expect, for example when using point-free definitions. It seems like the issue is the "...
Bakuriu's user avatar
  • 101k
185 votes
30 answers
885k views

How can I check if string input is a number?

How do I check if a user's string input is a number (e.g., -1, 0, 1, etc.)? user_input = input("Enter something:") if type(user_input) == int: print("Is a number") else: ...
Trufa's user avatar
  • 40.2k
307 votes
11 answers
307k views

Biggest integer that can be stored in a double

What is the biggest "no-floating" integer that can be stored in an IEEE 754 double type without losing precision? In other words, at would the follow code fragment return: UInt64 i = 0; ...
Franck Freiburger's user avatar
872 votes
52 answers
1.0m views

How do I check that a number is float or integer?

How to find that a number is float or integer? 1.25 --> float 1 --> integer 0 --> integer 0.25 --> float
coure2011's user avatar
  • 41.7k
41 votes
4 answers
73k views

Auto increment table column

Using Postgres, I'm trying to use AUTO_INCREMENT to number my primary key automatically in SQL. However, it gives me an error. CREATE TABLE Staff ( ID INTEGER NOT NULL AUTO_INCREMENT, ...
Jimmy's user avatar
  • 847
240 votes
2 answers
63k views

Which is the first integer that an IEEE 754 float is incapable of representing exactly?

For clarity, if I'm using a language that implements IEE 754 floats and I declare: float f0 = 0.f; float f1 = 1.f; ...and then print them back out, I'll get 0.0000 and 1.0000 - exactly. But IEEE ...
Floomi's user avatar
  • 2,633

15 30 50 per page
1
2 3 4 5
261