« first day (781 days earlier)      last day (4165 days later) » 

9:00 AM
@R.MartinhoFernandes Better still, scarf woven from beard hair
 
9:28 AM
mawning
 
jeu teu
@Pubby I think they might be illegal in public places in some countries, these days
@R.MartinhoFernandes I use both. Does that count?
But I get mocked a bit for bringing a scarf tound the year. I think this year I've only gone without for 4-6 weeks
 
lol
Why is Feeds posting a seemingly random question in here?
 
@TonyTheLion c++-faq
 
cpx
It seems OP has changed it's tag to both c-faq and c++faq
 
9:38 AM
There ought to be a surplus of moustache hair around at the moment, just in time to be recycled into scarves.
 
cpx
Can anyone decide it's question to be fit for an faq?
 
@cpx Usually it gets 'elected' so by the community (for C++, this lounge) or by nomination
 
@sehe oh right
 
@TonyTheLion Nonsense, the hallmark of sentience.
 
10:18 AM
slow week?
 
cpx
I remember in C++ I have used <bitset> to get bits of an integer into an array. Is there any function in C?
 
There are no functions in C.
 
@sehe yes, very.
 
@cpx also, bitset has nothing to do with integers, not arrays. It deals with bit sets :)
 
cpx
@StackedCrooked Really?
 
10:29 AM
Forsure
 
cpx
Oh okay. I guess I'll write a loop then.
 
@cpx the standards committee were getting worried about people getting confused between C and functional languages; they discussed it at the last meeting and decided to remove the functions. Problem solved.
 
Ah, my enemy. We meet again.
 
cpx
I'm not sure what functions are we talking about.
 
@R.MartinhoFernandes who, me? shirley not..
 
10:36 AM
@je4d No, ICU.
 
@R.MartinhoFernandes ah.. good luck with that
 
IIRC, C has bit types? A union of word32 uint32 with int bits:32 would work, no?
 
@je4d Better off without em.
 
11:00 AM
Yeah. It's one of the few areas where the C standardization committee is actually a bit ahead of the C++ one. I can't wait for this to be implemented in C++.
Really, we can do any functional stuff with templates these days, with the added benefit that it will be purely functional, and have no runtime complexity
 
At the risk of alienating everyone here... we should probably give the java guys some credit, they saw this revolution coming and did without functions from the start
 
cpx
Here's what I found:
1
A: Decimal to Binary

Aaron DufourHere's an elegant solution: void getBin(int num, char *str) { *(str+5) = '\0'; int mask = 0x10 << 1; while(mask >>= 1) *str++ = !!(mask & num) + '0'; } Here, we start by making sure the string ends in a null character. Then, we create a mask with a single one in it (...

How hard is that in C!
 
@cpx Soo, string to binary
Technically everything is binary already
Last I checked, we weren't using bits that hold up to 10 states
 
11:19 AM
or indeed, 0x10 states
 
@DeadMG I see what you did there..
 
cpx
integer to binary string, yes.
 
Request for comments on this, please:
@Dan That’s commendable, but his answer is factually wrong (and in a quite subtle way that is bound to confuse people) and upvoting the answer gives the impression that it’s correct, even if the comments say otherwise. I’d therefore ask you to please not upvote such answers in the future. — Konrad Rudolph 7 secs ago
 
agree
 
11:42 AM
0
A: Mandelbrot Set in OpenMP

seheFixing the approach as per the comment results in these timings1: Without openMP: $ gcc -std=c99 -O3 -march=native mandel.c && time ./a.exe real 0m12.324s user 0m0.000s sys 0m0.000s And with openMP enabled: User@IXL /cygdrive/e/mingw64 $ gcc -std=c99 -O3 -march=native -fop...

Dayum. Windows wouldn't even come with a PPM capable image viewer. I resorted to ASCII art :)
 
I don't normally think of parts per million as an image format
 
Another request for comments, please: is the template instantiation in this answer correct?
5
A: Why can lambdas be better optimized by the compiler than plain functions?

Konrad RudolphThe reason is that lambdas are function objects so passing them to a function template will instantiate a new function specifically for that object. The compiler can thus trivially inline the lambda call. For functions, on the other hand, the old caveat applies: a function pointer gets passed to...

 
yes
 
user1182183
12:26 PM
I'm kinda wondering why people instead of think about "why mirrors do not reverse up and down" they think about "why do mirrors reverse left and right"
 
user1182183
well the simple answer is that the mirror reverses front and back, left and right.. ;D
 
Am I the only one that upvotes people faster because they are regulars in this Lounge?
 
user1182183
that makes a full 2d inversion ;D
 
I'm terribly biased.
 
We're the only people who know anything on this terrible site, so
 
user1182183
12:29 PM
@TonyTheLion upvote because they 're in the lounge, nah not you only
 
I'm very generous in upvoting loungers
 
user1182183
however i'm the type of guy that most would like to downvote me but my questions are atonishing good IMHO, you just have to upvote them
 
@CatPlusPlus oh how terrible.
 
user1182183
however the stupid thing on SO is that if you ask the same question, which has been asked already, in another context, it's a valid, non-duplicate question.
 
user1182183
and people actually even upvote it
 
12:30 PM
don't start on SO's problems
there's many
 
user1182183
however there are bastard which see through the context thingy :P
 
user1182183
@TonyTheLion name more xd
 
user1182183
grr one of my salivary glands is "leaking" and in january I have to go on the operation table :/
 
user1182183
the damn hump under my cheek caused me a few days ago breathing trouble so I called the hospital and they sucked as much fluid as they could, out, but it keeps increasing and I have to wait a whole month for the operation :( and it's my first surgery ever in my whole life, i'm scared.
 
user1182183
12:35 PM
@CatPlusPlus why too much, Lion learns biology, maybe he can help me out xD
 
dude my biology knowledge is terrible
 
user1182183
@TonyTheLion ye anyway it fucking hurts when it gets bigger.
 
user1182183
13th december a MRI scan ;X
 
0
Q: Define macro for static member function

unresolved_externalI have a static function Util::GetTime What I want to do, is to declare a macros (or something else if that is possible) to redirect this static function calling to another function, e.g. Util::GetLocalTime without changing Util::GetTime function and without replacing this call directly in co...

I think OP is asking the impossible
3
Q: Why this 0 in ((type*)0)->member in C?

lxgeekthe code is: #define container_of(ptr, type, member) ({ \ const typeof( ((type*)0)->member) * __mptr =(ptr);\ (type*)( (char*)__mptr - offsetof(type,member) );}) Why this is ((type*)0)->member, not (type*)->member ? Thank you.

 
> static function Util::GetTime
Please tell me Util is not a class
 
12:40 PM
Util is not a class
there you go, I told you :P
 
12:58 PM
Ahahahahahahaha
Java is so fucking bad
Apparently something changed in JDK 7 and now tools producing .apk produce not working shit
 
ahahahahahahaha
I don't know why you kill yourself doing Java?
 
Because I have to maybe?
 
You never have to anything. You could choose to find something else, for example
Anyhow, if you're happy doing that, what should I care. It's just that you seem quite unhappy doing it, so I wondered why you don't do something to change it.
 
Job ain't bad
Technology bad
I'll probably eventually go towards my own thing, but now's not the time. I'm barely alive doing this stupid CS degree
 
1:16 PM
I know what you mean
they're worthless
 
so puppy, I may possibly have a job vacancy you can have a look at. If that would be an interest of yours?
 
yeah
it would be
 
ok when I get some data on what it is, I'll inform you.
 
thanks
 
1:36 PM
Room's rather slow today.
 
it's a slow room day
 
I have now finished beating ICU to a pulp, and came to unwind a bit, but apparently you guys suck.
 
we suck?
what are we sucking at?
 
Xeo
Entertaining the robot, apparently.
 
1:38 PM
Didn't think robot's needed entertaining
I thought they were merely built to work
and no entertainment modules were built in
 
Xeo
Apparently our robot "thinks" that is not the case.
 
If I had an entertainment module, I would not need you.
 
I suck at entertaining people
I'm probably the most boring person in the world.
 
Xeo
0
Q: Constant as rvalue in C++(11)

MartinWhy const int is not an R-value in C++(11)? I thought that R-value was 'anything' which cannot be on the left hand side and constants fulfil that. This code fails: int f(int && x) { return 100; } void g() { const int x = 1; f(x); } error: invalid initialization of reference of type...

Wow, big misunderstanding here.
 
2:06 PM
uh uh ah uh ah uh ah uh
wee
 
sup boring lion
what are you up to
 
-1
Q: c++ char value + "-some words here-" but error C2110

Wei KeatNormally I want a variable contain this "Hey you!". In Javascript we can var str = 'Hey' + 'you!'; In Web language we can $str = 'Hey'.'you!'; but in c++ + or . also cannot combine it.. Any ideas? I believe maybe it's just a simple thing but i really have no idea how to combine this i...

> In Web language we can [...]
 
No, it ain't PHP, it's teh Web Language now!
 
2:14 PM
@NolwennLeGuen being boring, as ever
I'm actually quite bored...
meh
 
Come and do prolog with me!
First order predicates are awesome!
Said no one ever!
 
> Use double quotes not simple quotes ... and it should work.
 
so how do you guys judge whether you like a job or not?
 
Well, if you like it...
 
2:20 PM
Do you like people there? Does it pay well enough to justify programming?
 
Pay is not an issue
 
Can you sleep till 11?
 
I wouldn't like it
 
people, I find harder
 
2:22 PM
Well
If you like your job you're probably happy to go to work.
 
16 mins ago, by Nolwenn Le Guen
First order predicates are awesome!
 
@sehe You didn't say that ;)
 
@NolwennLeGuen No. You did. And subsequently lied about it :)
 
oh, someone lied on the Internet
 
2:35 PM
Multiple times, actually
 
@sehe I typed it ;)
 
@NolwennLeGuen Oh my. I forgot the power of your troll
 
the troll side is strong in this one
 
Xeo
2:55 PM
> I think it has prvalue (Groan!). stroustrup
lol /cc @R.MartinhoFernandes
 
I have teeth
 
how many?
 
I dunno
what do I look like, a dentist?
 
For a big project, would you choose c++ or delphi?
 
c#
 
3:06 PM
and why?
 
Xeo
@user1860848 PHP
 
sigh every language has their own ups and downs. You choose a language for your project based on what the project is, not by the size.
 
size of a project should be a deciding factor in a language choice, you can do server side in c++ and client in c#/delphi
 
Xeo
@Kimi s/should/should not/
 
I mean should NOT
:)
 
3:11 PM
Well for example a Delphi pros are the readability of the code and VCL.
 
what are you trying to make?
 
Xeo
-2
A: Elegant solution for coloring chess tiles

KevinAlthough this approach isn't really necessary for something as simple as a chess board, when I think of an elegant way to render something related to the view, I want to make it as easy as possible to change the rendered view as possible. For example, suppose you decided you wanted to alternate b...

o_x
 
I was asking for an opinion :)
 
Xeo
Cool, our opinion is "decide for yourself".
Really, it all depends on the team and the project. Not the size.
 
size doesn't matter
 
3:22 PM
There are languages that are terrible at big codebases.
C for one
It takes a whole lot more of self-discipline and effort to keep large C codebase decent
2
 
hi guys
 
hi
so how's your new job
 
Not enterprisey enough, needs more XML. — mh01 2 hours ago
^ hahaha
I'm in holidays right now
I start next week.
So I'm playing around with iOS and stuff
Also "Nolwenn Le Guen" wtf?
 
Xeo
@StackedCrooked: "main.cpp:23:6: error: right operand of comma operator has no effect [-Werror=unused-value]" -- would you consider taking the -Werror out or sanitizing it a bit? :s
 
@kbok Why ios. Why.
 
3:32 PM
did you mean "Nolwenn Leroy" ?
because I'll be tasked to do some iOS stuff, that's why.
 
Xeo
@kbok Why would she?
 
because that would be funny
 
is there a fast prime factorization C++ code out there?
have looked everywhere to no avail
 

Help Desk

For Turbo C/C++ and Dev-C++ questions
 
3:45 PM
@kbok My condolences.
 
user784668
3:59 PM
@CatPlusPlus "C codebase decent"
 
user784668
What.
 
impossibru
 
user784668
@DeadMG I actually know how to do it. It's "rewrite it in C++".
 
@KaliMa There are no fast prime factorization codes - full stop.
 
> What if you strapped C4 to a boomerang? Could this be an effective weapon, or would it be as stupid as it sounds? —Chad Macziewski
> Aerodynamics aside, I’m curious what tactical advantage you’re expecting to gain by having the high explosive fly back at you if it misses the target.
 
4:05 PM
@DeadMG Probably meant "integer factorization in prime components" or sumthin
 
same answer
 
Generally called "integer factorization" anyway
 
integer factorization is an NP-hard problem
so unless you have a quantum supercomputer, you can forget it being fast
 
Uh
It all depends on your definition of "fast"
 
It's still fast for small numbers
 
user784668
4:07 PM
@kbok For small numbers you can use a LUT, so it's slow even for these.
 
A LUT ?
 
user784668
@kbok Look-up table.
 
Oh, yeah.
 
Okay, so, it's much colder this morning.
 
@R.MartinhoFernandes is you ere roboticus?
 
4:18 PM
@DeadMG It's not known to be NP-hard, and nobody knows whether there may be faster methods of factoring than are currently known. Even within the currently known methods, there are adjustments that can be made, so even though the basic algorithm is the same, factoring with the General Number Field Sieve is faster now than it was 10-15 years ago.
 
huh
coulda sworn that integer factorization was essentially the same problem as discrete logarithm which is NP-Hard
but Wiki doesn't mention any such equivalence
 
someone knows a time librarie for c++? something which has abstract use of hours seconds and stuff
 
Xeo
<chrono>
 
<chrono>
 
<ctime> <- is best
 
Xeo
4:21 PM
And the insect gotta troll, of course.
 
user784668
@alfalfa <chrono>
 
I'm having a bit of a brain fart right now...having two identical functions in different .c files of the same project gives me "multiple definition" linker errors
 
k got it, ty
 
@Xeo Don't spoil it!
 
need to inline.
 
4:22 PM
@DeadMG fast for numbers <30k or so
 
oh, C's inline is not the same as C++'s inline.
 
user784668
14 mins ago, by Fanael
@kbok For small numbers you can use a LUT, so it's slow even for these.
 
@DeadMG I can intuit such a relation, but I haven't heard of it before. You might have found that kind of relation in a text on arbitrary precision integer arithmetics (e.g. Numerical Recipes) because it sounds like something that could come in as an optimization for very large capacity calculations
 
and yes i mean factoring a number into integer primes
like 28 -> 2,7
 
@melak47 No shit
 
4:23 PM
@DeadMG You mostly use the same algorithms for both, yes. Neither has been proved to be NP-hard, though no polynomial-time algorithm is known for either one.
 
I'm not technically allowed to modify the makefile, so putting those functions in a shared .h/.c pair isn't technically allowed :/
so, renaming each copy it is? :(
 
No
Make them static
 
@KaliMa paging Dr. Seuss Mysticial
 
user784668
@melak47 You have to modify the makefile to add a source file?
 
@Fanael Not that uncommon
 
4:25 PM
@Fanael yes, files are explicitly listed in the makefile
 
Do the functions have to be seen across compilation units?
If not, make them static and remove them from the .h
 
Xeo
Hm, crap. Trying to create an is_container_of<Cont, Type> trait, I run into a problem. is_container is implemented as all_of<is_container<Cont>, is_value_type_same<Cont, Type>> and is_value_type_same is implemented as std::is_same<Strip<decltype(*std::declval<Cont const&>().begin())>, Type>.
This all works just fine as long as you don't try to call the a function that is EnableIf<is_container_of<...>>'d with a fundamental type, as the *declval<Cont const&>().begin() part will result in an error which will not be lifted to a SFINAE error. :(
 
user784668
Oh.
 
Xeo
Any ideas on how to work around that? /cc @LucDanton @R.MartinhoFernandes
 
user784668
I'm using GCC 4.7.0.
 
4:26 PM
Far Cry 3 is an excelent knife-to-the-throat simulator.
 
@NolwennLeGuen they aren't in any .h files
 
@melak47 Then static.
 
user784668
And I wondered why GCC has problems with building itself.
 
user784668
FWIW: building GCC using GCC version X, changing the system compiler to GCC version Y and then trying to do an unclean make is not a good idea.
 
@NolwennLeGuen thanks :)
 
user784668
4:32 PM
Can haz cloze vote?
 
user784668
-7
Q: Focus on two windows at the same time

blackWorXSo i bought a new LG 3D-TV that has this realy cool function called Dual-Play. This gimmick just takes the split-screen, projected on the tv and streches it to the whole area. Player one then sees though his glasses only his Split-Screen and player two sees his screen. My idea is, to fake this w...

 
man it's like no code exists online for this
i already have code that is sqrt(n) time but I know there's a faster one
 
@KaliMa How big of a number do you need to factor? You can do it pretty quickly up to around 90 decimal digits or so. By 100 digits, it can be pretty slow (presuming you're looking at the product of two large primes). By 120 digits, you can pretty much forget it unless you have a supercomputer handy. The big problem isn't CPU speed, it's memory -- for a 120 digit number, the GNFS requires something like a couple terabytes of RAM.
 
@JerryCoffin I am factoring numbers mostly <30k
 
user784668
@KaliMa Then LUT.
 
4:34 PM
LUT?
 
user784668
@KaliMa Look-up table.
 
@KaliMa Lookup table.
 
how?
i am currently using trial division method
i just feel like trial division is too "naive"
and there is probably a faster way
 
user784668
@KaliMa Premature optimization.
 
user784668
@KaliMa For such small numbers, everything will be fast enough.
 
4:37 PM
Not sure what I was thinking. To build a LUT for numbers in that range, you want to use the sieve of Eratosthenes (or a variant thereof). The variant would be if you want factors, not just to know if it's a prime.
 
I tried looking for code like that Jerry
Something that used a sieve to make all primes <max number
and then figure out some way to combine those primes together to factorize n
but i couldn't find any such code
 
user784668
@KaliMa Think for a while, then.
 
That's where the variant comes in -- instead of just "crossing out" a number when you encounter it, you record the smaller number as a factor of the larger.
 
can you give an example?
 
user784668
brb reboot
 
4:44 PM
For each number, instead of just a Boolean indicating whether it's prime, you'll have a vector of factors. So, as you walk through multiples of 2, you won't just cross them off as composite -- you'll add 2 to their list of factors, so it'll be added to the factors for 4, 6, 8, etc. Then you'll do the same for 3, adding it to the list of factors for 6, 9, 12, etc. From there, it becomes a question of whether you want all factors of a number, or just the prime factors.
If you just want prime factors, skip 4 because it already has a factor in its list. Otherwise, go through and add 4 as a factor to 8, 12, 16, etc. (and continue on for 5, etc.)
 
i don't understand
all i want is primes, not the divisors
 
@KaliMa And you think divisors are not primes?
 
they are not necessarily prime
6 is a divisor of 12 but 6 is not prime
 
@KaliMa 6 is 2 and 3, though, and those are both prime.
 
but then i have to waste time breaking down potentially redundant factors
break down number -- are these numbers in my list? scan everything, etc
 
user784668
4:50 PM
@KaliMa That's why Jerry's suggesting you use a modified sieve of Eratosthenes.
 
that's what i am asking about
i need a concrete example or something bc i don't understand what he is saying
 
Sigh
Use your brain pls
 
So, you want someone to write your code for you?
 
user784668
@KaliMa How much are you willing to pay?
 
I'm not asking anyone to write my code
I'm asking for an example
 
4:52 PM
@KaliMa Yes, as I said, if you only want the prime factors, then when you get to a number that already has at least one factor in its list, you skip it.
 
@Xeo Done. (This is the easiest type of request :D )
 
@KaliMa What kind of example?
 
of how the algorithm would work
i don't understand what is so hard about this question?
 
Xeo
@StackedCrooked k, thanks. What about the 2-space-indent request? :P
 
where did i ask anyone here to write code for me?
please do not put words in my mouth
 
4:54 PM
Do urself a favor and use haskell for this :-p
now I quietly go back to what i was doing...
 
Woa, no need to get agressive.
 
@Xeo Everyone knows 4-spaces is best.
 
And I was asking a question.
 
Xeo
@StackedCrooked Pff! Can you atleast change it to spaces then?
Cause right now, it's tabs, IIRC.
 
tabs are evil :-(
 
4:55 PM
Oh yeah, that should be changed.
 
user784668
@StackedCrooked 3-spaces is bester.
 
user784668
@StackedCrooked And π-spaces is definitely the bestest.
 
Xeo
Where n == 2.
 
user784668
@Xeo It's π. As in "pi". As in 3.14159…
 
@StackedCrooked Except for HTML and other heavily indented languages (like JS)
 
Xeo
4:57 PM
@Fanael Oh, I see.
 
@BeyondSora While Haskell might indeed work well, let's be real: this would have been easy to solve in Apple Integer BASIC. It doesn't require a whole lot of sophistication.
 
user784668
@JerryCoffin This would've been easy to solve in PHP.
 
@Fanael I have considerably less confidence in PHP than Integer BASIC.
 
how much memory would be required to make a list of prime factors for N = 1 to 25k or so?
if i am understanding jerry correctly
he's saying i need to make a vector of vectors / double array / etc that has n and then a list of factors for that n?
 

« first day (781 days earlier)      last day (4165 days later) »