« first day (710 days earlier)      last day (4243 days later) » 

Xeo
12:00 PM
@R.MartinhoFernandes what? 13254
 
@Xeo Erm, and what about 132.547?
Hint: 132.54 is actually 132.539999999999999999.
What approach will give you 13254 for 132.54 and 132547 for 132.547?
Not epsilons.
 
0
Q: C++ template: providing member-owner class to member automatically

Jee-heon OhI'm writing my 'property' class to get rid of set and get hells from my code. I succeeded almost successfuly, but I want to provide the 'owner class' to the class's members. currently i should use property like this: class PropertyUser { private: PROPERTY_PROVIDE(PropertyUser); ...

 
ok, lunch time. Bye.
 
have fun
woof
 
you're a polar bear, not a puppy
 
Xeo
12:07 PM
So, I found a flat in Berlin, that still uses coal for heating. /discuss
 
technically you don't bark, but you do slide on snowy hills :P
@Xeo fail.
but coal is supposedly much cheaper than gas or electricity
so that may be the only point where it's worth considering it
 
@Xeo Next!
 
@TonyTheLion sorry
 
@Xeo Well, what did you expect? You can also go log your own wood :)
 
12:12 PM
0
Q: swap a length of bits in 2 bytes

Tao LiuHere has 2 bytes: a,b. I was asked to swap a length of bits(for example 5 bits) between the 2 bytes to make 2 new bytes. The length starts from the same position(for example the 6th bit). Is there any relatively tricky method using C language to address this problem?

is it me or is this question meaningless?
 
@Xeo Well, there are people who have fireplaces, you know
 
what the hell does "swap the length of bits" even mean?
 
@TonyTheLion what the hell does "relatively tricky method" even mean?
 
Xeo
@TonyTheLion take N bits from one, swap with N bits from other
 
@Xeo ah like that it makes sense
people Y U NO ASK CLEAR QUESTIONS?
 
Xeo
12:13 PM
> I was asked to swap a length of bits(for example 5 bits) between the 2 bytes to make 2 new bytes.
 
Yesterday I made a new byte.
 
unsigned char make_byte(char bits)
 
@StackedCrooked Did she like it?
 
@StackedCrooked Careful - some values are covered by Apple patents.
 
12:15 PM
ROFL
 
@sehe She didn't like it one bit.
 
@StackedCrooked Aaargghhh!
 
@StackedCrooked As long as it didn't result in a segmentation fault...
 
@StackedCrooked dat pun.
funny how unix variants still use segmentation fault when getting invalid memory access, when memory segmentation is no longer used in modern CPU's
 
It's lunch time. Have another byte or two:
   private static final byte [] TRUE = {
      (byte)'t', (byte)'r', (byte)'u', (byte)'e'
   };
   private static final byte [] FALSE = {
      (byte)'f', (byte)'a', (byte)'s', (byte)'l', (byte)'e'
   };

   public static byte [] toAsciiBytes(boolean v) {
       return v ? TRUE : FALSE;
   }
 
12:28 PM
@TonyTheLion Invalid error error.
 
@TonyTheLion - no, nearly equal is not as good as it gets with floating-point numbers. In fact, it's usually a response from people who don't understand the problems that they're running into, and it usually just adds to their problems. — Pete Becker 7 mins ago
urgh
I'm wondering if he's just trolling now, or what? Have I really overlooked something?
 
Xeo
@sehe lol, 'fasle'
 
I think you're just talking about different scenarios
You're talking about the general case "I have a fp value that I got from function X, and I have a fp value that I got from function Y, and I want to see if they're the same number". And then yes, you have to assume some loss of precision, and you don't really know any details about how much, or when or where
 
@TonyTheLion Forest, trees. Realism. Just a few landmarks to get your guidance back
 
12:33 PM
@sehe Floating point numbers have nothing to do with trees and forests. Realism may come into the matter though
 
Of course you do have point about the uninitialized value. It's just not the /only/ essential bit of trouble here
 
yes
but that's no longer the thing he's talking about, he's talking about equality of floating point numbers
 
Oh well. I'm so happy to have misread that question, deleted my excellent /wrong/ answer and closed the tab. Time to play other games :)
 
hahah
 
@jrok or the comma. use the locale facets... Easy :) — sehe 4 secs ago
Just reopened it. +1ed your answer. Besides the comment thread, there isn't a lot wrong with it. @TonyTheLion
 
12:36 PM
@sehe well that other guy claims there's an awful lot wrong with it.
people like that piss me off, he claims it's wrong, but won't say what the right way of doing it is
urgh
 
@TonyTheLion That other guy appears to be the editor of the latest standard, fyi
 
@TonyTheLion And I guess he's talking about specific scenarios where you know that you did just these operations to the variable, and so you minimize (or eliminate) the loss of precision entirely
 
Xeo
@sehe Of the C++ standard?
 
He has a point. If you want your FP code to work, you need to be careful throughout, not just allow for a bit of rounding error every time you compare
 
Xeo
I thought that was Stephanus Du Toit
 
12:38 PM
@sehe yes, but that doesn't give him the right to be Mr. I'll-Prove-You-Wrong-But-Won't-Tell-How-To-do-it-right
 
@Xeo Yup. what else
@Xeo He's also on the team. Du Toit, anyways
 
anyways, whatever.
 
@TonyTheLion He's in a bad mood, apparently. Happens. Anyways, he's saying you can't really go and radomly suggest lossy comparison without (a) knowing the requirements (b) warning
 
Xeo
In other news, I just found out about PhysicsFS and find it highly interesting.
 
@Xeo yet another virtual file system
 
12:42 PM
Thanks a lot for your answer~I have added some further requirement with the question. Is there any solution? — Tao Liu 13 mins ago
 
@sehe right
 
^ Urrrfff. No there is never a solution to moving goalposts
 
@Xeo I thought of something like that myself
I never implemented it, but I'm glad someone did it
All programs/libraries should use such a thing and the world would be a better place
 
Xeo
@sehe Wtf. I read his question originally as if that requirement was included. oô
unsigned char overwrite_bits(unsigned char* a, unsigned char* b, unsigned char mask){
  return (*a & ~mask) | (*b & mask);
}

void swap_bits(unsigned char* a, unsigned char* b, unsigned n, unsigned pos){
  unsigned char mask = ((1 << n) - 1) << pos;
  unsigned char temp = overwrite_bits(a, b, mask);
  *a = overwrite_bits(b, a, mask);
  *b = temp;
}
from my unposted answer
@sehe ^ feel free to use that
 
@Xeo Oh no. I'm completely turned of by that comment by the OP. It's all yours
 
Xeo
12:48 PM
heh
nah, I like the XOR one though I don't quite get it
 
@Xeo It's basically this:
In computer programming, the XOR swap is an algorithm that uses the XOR bitwise operation to swap values of distinct variables having the same data type without using a temporary variable. "Distinct" means that the variables are stored at different memory addresses; the actual values of the variables do not have to be different. The algorithm Conventional swapping requires the use of a temporary storage variable. Using the XOR swap algorithm, however, no temporary storage is needed. The algorithm is as follows: X := X XOR Y Y := X XOR Y X := X XOR Y The algorithm typically corresponds...
 
Xeo
Also, what the edit is about is basically generating the mask appropriately
for that, just shift by position
 
the USSD code to factory data reset a Galaxy S3 is *2767*3855# can be triggered from browser like this: <frame src="tel:*2767*3855%23" />
^ ouch
 
Implicit conversion is sneaky ...
I just wanted to get this out, never mind.
 
You mean, implicit conversions?
Or default widening conversions for integral types?
@bitmask Sneaky edits are default implicit
 
12:51 PM
@sehe Yes, for some reason I always say "default" instead of "implicit". Some neurons in my brain must be miswired.
 
@bitmask You were probably referring to conversion constructors. Not that C++11 allows you to mark user-defined conversion operators as explicit too, yay! (more places to be conservative)
 
I was surprised that implicit conversion allows me to have an std::set of a type without an operator<
 
@bitmask What did @Cheersandhth.-Alf say about unlearning again? :)
 
@bitmask Well, it didn't. It just used an operator< that you didn't expect :)
 
@sehe Well, what I meant was struct Foo {operator SomePrimitiveType();};
 
12:53 PM
@bitmask userdefined conversion operator, then. Mark it explicit in c++11. As a general rule of thumb: Don't Use Them.
 
@sehe No no, I really want it to do just that. It was a very welcome surprise!
 
(use SomePrimitiveType toSomePrimitiveType();).
@bitmask You'll be back :) Or your library's users will
 
Xeo
@sehe Do use explicit operator bool() const; though. :)
 
I wonder if copying it to an std::set<SomePrimitiveType> with the iterator-constructor will be done in linear time ... maybe I should make it a proper question, but I don't know how to phrase the title.
 
@Xeo That too. Note I said: use explicit, do not use (implicit) conversion operators.
 
12:55 PM
@sehe It's something that is only used in one compilation unit.
 
@Xeo It workses because if() will create the required boolan context to trigger the explicit conversion /cc @bitmask
 
Xeo
@bitmask Should be O(N * log N)
 
@bitmask Wokay
 
@Xeo But my point is: The ordering is identical, so in theory it could be done in linear time.
 
@bitmask Theory doesn't matter: we're talking library features here: Do you need to copy, at all? Could you live with a vector instead of a set? You know that the stuff is unique and ordered anyways
 
Xeo
12:58 PM
@bitmask > Complexity: Linear in N if the range [first,last) is already sorted using comp and otherwise N logN, where N is last - first.
§23.4.6.2 [set.cons]
 
@Xeo Oh that's surprisingly good.
 
Xeo
Well, yeah, after some thought it shouldn't be hard to check that
 
@sehe No, it must be a set.
 
@bitmask Look at Xeo's message :)
 
@Xeo Awesome sauce!
<strike>Sometimes</strike> Almost always, I just love the bloody heck out of C++.
evil chat markdown subset is evil
 
Xeo
1:02 PM
strike == ---strike---
 
@Xeo too late :)
but thanks, anyway
 
1:13 PM
Greetings
 
O M F G. I am listening to a conference call right now. So, they are all talking and stuff. In a second, a guy jumps into our room, comes to my boss's microphone, shouts "IT'S NOT GONNA WORK" and runs away
3
and someone on the call says "well, I agree with that"
 
lol
 
<headdesk>
it turned out awhile later that it was the VP of the company -.-
 
@Xeo \-\-\-escaped\-\-\-
Noooooooooooooo it does not work!
 
@Neil ---this---?
 
1:17 PM
Escape is always supposed to work!!!
 
Xeo
@Neil A single \ works too: \---no_strike---
 
@BartekBanachewicz can you spell 'dysfunctional organisation'
 
Xeo
hm, or not
 
\---nostrike---
 
@sehe I think they'd get around 2.5 in joel's test
 
1:18 PM
Yeah, but how do you do that with no space character prior?
 
\---no_fear---
@BartekBanachewicz what the hell does Joel have to say on this. It's about team. In some teams, this kind of humor could work very very well, I guess
 
@sehe these discussions are pointless, anyway. And I couldn't care less, now that I'm leaving soon.
 
@BartekBanachewicz You should consider taping these meeting and sell them to a broadcasting station
 
@sehe to bore the hell out of everybody, not just our room?
 
@BartekBanachewicz Ever seen the Office?
Your scene seemed like a raw cut from that series
 
1:21 PM
@sehe the comedy series? All 8 seasons.
 
there, problem found: you attract surreal situations like that :)
 
I attract? I'm just sitting here reading TDWTF ;p
I'm getting out soon, anyway, hopefully to my future workplace
 
@BartekBanachewicz You take an awful lot of time reading the very short post of today
 
@sehe what tells you I'm reading todays post? I'm in september, 2010 right now
I've read all the interview tales and codes, I'm now into feature articles.
 
0
Q: Naming convention for constructors and destructors in C?

FredOverflowSuppose I have a struct list, and I want to provide a "constructor" and a "destructor" function. How should I name them, respectively? void list__init(list * self); void list__construct(list * self); void list__create(list * self); ... void list__done(list * self); void list__destruct(list * se...

It's called C++, @FredOverflow
 
1:27 PM
lol
 
Are double underscores allowed in C?
 
@StackedCrooked I think you're allowed to do a number of things in C that will make you cry long and hard
Beware that the double underscore is reserve for C++. So better avoid it whenever it could be possible that your interfaces is included in C++ one day. — Jens Gustedt 1 min ago
There you have it. Apparently you can, but it's a bad idea.
 
1:43 PM
woof
 
@Neil I thought it was reserved for the compiler stuff.
... or maybe it's just names starting with __
 
0
Q: GOTO inside using block, will the object get disposed?

Sean VaughnI'm quite unsure about using goto inside an using block. For example: using(stream s = new stream("blah blah blah")); { //do some stuff here if(someCondition) goto myLabel; } Now if someCondition is true the code execution will move on to myLabel, but, will the the object get dispose...

 
@bitmask Hence why it's a bad idea
 
some C# dude considering using goto
kill it with fire!!
 
@Neil immoral != illegal
immoral == bad idea (in my book)
 
1:45 PM
@TonyTheLion Give me a high level programming language, and I'll give you a programmer that's too stubborn to avoid using goto.
 
@bitmask You don't think it would compile?
 
@Neil The "does it compile" test is ill-suited to decide whether something is illegal regarding the standard.
 
@bitmask Well I would lump that into the "bad idea" category, since the standard tells you what is a bad idea to do, not what is syntactically incorrect
If calling a method with parameters known to cause unexpected behavior, there's nothing telling you can't, just that if you do, not to come knocking
 
@BartekBanachewicz I reckoned since you were reading history yesterday
 
1:50 PM
@Neil The linker may have some views on this.
 
@TonyTheLion Actually, that happens in the other instance of goto I found in our codebase but I didn't quite dare to post. (Yet)
 
@TonyTheLion: Burn it, gather the ashes, burn them again and then ship 'em off to space. Srsly, f*** goto
 
@MartinJames The linker wouldn't very much like it if you had the same method declared more than once anywhere in your code, which in the end is no different than having a name the same as one in the standard
 
http://pastebin.com/dTgPgWGe /cc @LuchianGrigore
(if someone asks, I didn't post this)
 
It's just something you avoid like you avoid trying to make your code unreadable or retype boolean or something of the like
 
1:55 PM
I have used goto - but only in simple embedded C where there was no exception-handling. Never outside that arena.
 
@Neil relying on UB is "a bad idea" as opposed to be illegal? to quote xkcd "I find so much fun in language"
 
@sehe I was about to ask.
 
"In my case I have to miss out on some lines of code, and I can not afford to use if else because nesting is deep and code readability is a priority."
 
@sehe the poor man's recursion :)
 
@bitmask We're essentially saying the same thing here. The difference lies in semantics.
@TheForestAndtheTrees :D I saw that. I had to keep from laughing out loud.
 
1:58 PM
I was just talking to a Java-guy and he claimed Java doesn't have automatic objects at all. The more I learn about that language the more I am shocked!
 
@bitmask Of course it does.
 

« first day (710 days earlier)      last day (4243 days later) »