2,725 reputation
1219
bio website zvrba.net
location Oslo, Norway
age
visits member for 3 years, 6 months
seen Jul 13 '13 at 20:50

May
30
awarded  Nice Answer
May
23
answered Excellent knowledge of C++
May
23
comment Excellent knowledge of C++
I have no idea why you got downvoted, it's the most sane answer.
May
13
answered Should I use the new C++11 'auto' feature, especially in loops?
May
12
comment Should I use the new C++11 'auto' feature, especially in loops?
+1 for the example, but that also tells something about the state of "modern" C++.
May
10
answered Books having graded collection of programming problems
Apr
30
comment When should you use bools in C++?
@EmilioGaravaglia No, it's not how MS decided to implement it -- C++ standard mandates that the contents of a bool variable shall be a numeric zero or one. And Intel CPUs can handle 8- 16- and 32-bit data equally well, no masking needed. [Though, mixing various widths always requires sign- or zero-extension, but that's the semantics of operations.]
Apr
30
comment When should you use bools in C++?
@Martin I mean this: msdn.microsoft.com/en-us/library/b6801kcy.aspx Integers are perfectly good boolean values, but when the compiler has to assign anything to a bool, it must guarantee that the stored value is numerical 0 or 1. Meaning, bool z = x & 16384 != 0 will generate larger (and slower) code than int z = x & 16384, but both will achieve equivalent effect in any conditional. A much more useful bool type would NOT be implicitly convertible to/from an integral type, and normalization, if necessary, would occur during read/write.
Apr
25
comment How to be a successful programmer without a CS degree
Trying to forecast the industry is a game lost upfront [e.g., I'm not sure that anybody could've guessed that Twitter -- (almost) IRC clone for the web -- would become such a fad. It's still a mystery to me how they intend to make money in the long run.]. You have to take a proactive choice about what kind of job you'd like to do and find out what it takes to get that. How? Find somebody already working in your target industr(y|ies) and talk with them.
Apr
24
awarded  Nice Answer
Apr
24
comment How to be a successful programmer without a CS degree
@PaulHazen See the new edit (starting at UPDATE2 -- it didn't fit into the comment field ;))
Apr
24
revised How to be a successful programmer without a CS degree
added 2474 characters in body
Apr
24
comment When should you use bools in C++?
Except that in C++, bool a=5; is perfectly OK, but the compiler will generate the code to always coerce the RHS to 0 or 1. So bool in C++ has no benefits with the downside of making code larger and slower.
Apr
24
revised How to be a successful programmer without a CS degree
added 270 characters in body
Apr
24
answered How to be a successful programmer without a CS degree
Apr
20
comment When should you use bools in C++?
Unnecessary use of if() award. Just write return value >= 0; for the first example.
Apr
17
comment Is it a good practice to use smaller data types for variables to save memory?
@JeremyP It forces you to write ugly code like (int)salary1 - salary2. If you have some invariants to preserve, encapsulate the data into a class. Though: why isn't the difference a salary? Addition and subtraction preserve physical quantities (e.g., the difference of velocities has the same units [m/s]), so what makes salary special?
Apr
17
comment Is it a good practice to use smaller data types for variables to save memory?
Using unsigned in this case is a bad idea: not only the salary cannot be negative, but the difference between two salaries cannot be negative either. (In general, using unsigned for anything but bit-twiddling and having defined behavior on overflow is a bad idea.)
Apr
5
answered Why would you use data structures (ie Binary Trees, Linked Lists) in your jobs/side projects?
Apr
5
comment Why would you use data structures (ie Binary Trees, Linked Lists) in your jobs/side projects?
Modern CPUs love sequential accesses. Anything else, unless you're careful about placing data in memory, kills performance.