Questions tagged [representation]

291 questions
305
votes
13 answers

How to print (using cout) a number in binary form?

I'm following a college course about operating systems and we're learning how to convert from binary to hexadecimal, decimal to hexadecimal, etc. and today we just learned how signed/unsigned numbers are stored in memory using the two's complement…
Jesse Emond
  • 7,180
  • 7
  • 32
  • 37
156
votes
7 answers

Fixed point vs Floating point number

I just can't understand fixed point and floating point numbers due to hard to read definitions about them all over Google. But none that I have read provide a simple enough explanation of what they really are. Can I get a plain definition with…
user942451
  • 1,595
  • 2
  • 12
  • 6
77
votes
2 answers

Is there any graphical representation of Android views lifecycle (a state diagram)?

We all know about the Android Activity's life cycle and Fragment's life cycles. But is there anything equivalent for views ? This could help, for instance, building custom views or give an in-depth look at a very common and often hidden graphic…
Snicolas
  • 37,840
  • 15
  • 114
  • 173
56
votes
5 answers

Malformed String ValueError ast.literal_eval() with String representation of Tuple

I'm trying to read in a string representation of a Tuple from a file, and add the tuple to a list. Here's the relevant code. raw_data = userfile.read().split('\n') for a in raw_data : print a btc_history.append(ast.literal_eval(a)) Here is…
50
votes
3 answers

If the size of "long" and "int" are the same on a platform - are "long" and "int" different in any way?

If the representation of a long int and a int are the same on a platform, are they strictly the same? Do the types behave any differently on the platform in any way according to the C standard? Eg. does this always work: int int_var; long…
Vilhelm
  • 717
  • 1
  • 7
  • 12
49
votes
2 answers

Are there any non-twos-complement implementations of C?

As we all no doubt know, the ISO C standard (and C++ as well, I think, though I'm more interested on the C side) allows three underlying representations of signed numbers: two's complement; ones' complement; and sign/magnitude. Wikipedia's entry…
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
40
votes
16 answers

What's the biggest number in a computer?

Just asked by my 5 year old kid: what is the biggest number in the computer? We are not talking about max number for a specific data types, but the biggest number that a computer can represent. Infinity is not allowed. UPDATE my kid always wants to…
Yehonatan
  • 1,172
  • 2
  • 11
  • 21
25
votes
7 answers

When and how is conversion to char pointer allowed?

We can look at the representation of an object of type T by converting a T* that points at that object into a char*. At least in practice: int x = 511; unsigned char* cp = (unsigned char*)&x; std::cout << std::hex << std::setfill('0'); for (int i =…
Joseph Mansfield
  • 108,238
  • 20
  • 242
  • 324
21
votes
3 answers

How can we get the default behavior of __repr__()?

If someone writes a class in python, and fails to specify their own __repr__() method, then a default one is provided for them. However, suppose we want to write a function which has the same, or similar, behavior to the default __repr__(). However,…
Toothpick Anemone
  • 4,290
  • 2
  • 20
  • 42
20
votes
5 answers

Haskell - How to best to represent a programming language's grammar?

I've been looking at Haskell and I'd quite like to write a compiler in it (as a learning exercise), since a lot of its innate features can be readily applied to a compiler (particularly a recursive descent compiler). What I can't quite get my head…
Peter
  • 435
  • 1
  • 4
  • 9
20
votes
2 answers

Binary representation of a .NET Decimal

How does a .NET decimal type get represented in binary in memory? We all know how floating-point numbers are stored and the thusly the reasons for the inaccuracy thereof, but I can't find any information about decimal except the…
Squirrelsama
  • 5,480
  • 4
  • 28
  • 38
19
votes
4 answers

How to use Int64 in C#

The question is easy! How do you represent a 64 bit int in C#?
user182513
19
votes
2 answers

Finite automaton in Haskell

What is a good way to represent finite automaton in Haskell? How would the data type of it look like? In our college, automata were defined as a 5-tuple (Q, X, delta, q_0, F) where Q is the set of automaton's states, X is the alphabet (is this…
mathemage
  • 356
  • 3
  • 11
16
votes
3 answers

Lisp: How to override default string representation for CLOS class?

In Common Lisp, how can I override the default string representation of a CLOS class so that calls to format or princ will print something intelligible, even when objects of that class are embedded within other types, such as lists or arrays? For…
sadakatsu
  • 1,255
  • 18
  • 36
15
votes
2 answers

How does the mechanism behind the creation of boxed traits work?

I'm having trouble understanding how values of boxed traits come into existence. Consider the following code: trait Fooer { fn foo(&self); } impl Fooer for i32 { fn foo(&self) { println!("Fooer on i32!"); } } fn main() { let a =…
Askaga
  • 6,061
  • 5
  • 25
  • 49
1
2 3
19 20