« first day (517 days earlier)      last day (4423 days later) » 

12:00 AM
the posted code is good
except i would have filled in the two 1 values in the vector declaration
 
obviously not
 
In C can I copy content of a file without knowing it size into an array?
 
i might have botched up my modulus code somewhere
 
@LearningC What did I tell you about asking random C questions?
 
@john can you post the code that isn't working?
 
12:01 AM
Well chat is faster than asking on question.
 
that is not any more my problem now than it was the last time
 
lol
 
next time I will simply Bin your messages
 
what is Bin?
 
it effectively means "delete"
 
12:02 AM
oh
what is hellfire?
 
@LearningC if I can't answer it in one line, it probably shouldn't be asked in chat
 
lol
then hellfire is a very good word to describe it.
 
my modulus code is a little weird
because i am also trying to account for divisors
 
-1
Q: const unsigned char* conversion to/from string or const char*

CarrieI am lost in the underworld of pointers! Here is my problem, It is very quirky and I can only control one of the functions so please don't say I need to redesign. This is being compiled in Linux Ubuntu 11.04 using android-ndkr7. It is a purely native application (or service) that will run on a...

 
e.g. n!/arbitrary value
which isn't so nicely converted in mod m
so i try to exclude arbitrary value in my factorial
 
12:06 AM
^ is it a coincidence that such question is posted by a person with girl name? i think, advanced trolling.
 
@JohnSmith if that's relevant, I didn't understand
 
whilst also taking modulus
sorry
 
@john i find it easier to think in terms of "mod 10". like, 123*456 mod 10, the product is some huge number and the final result is just last digit. then 123*6 must produce the same result, because 123*450 ends in 0 as last digit.
@john do you understand that?
 
i understand but what i mean is i can't find n!/c mod by doing n! mod m and then somehow dividing it by c or c mod m
it won't work
 
right
you have to do that mod thing for each multiplication, to keep the numbers in a range you can handle
note that 123*6 mod 10 must also, necessarily, be the same as 3*6 mod 10
so now we know the anser, it's 8
without calculating the big product
:)
 
12:14 AM
what does this error mean passing argument 1 of 'fgets' from incompatible pointer type [enabled by default]
does it mean whatever I'm pass is not a pointer?
 
^ re the posted question, i will naturally not answer "carrie"'s response, where she accuses me of being a "hater". i think i was spot on predicting what it was all about :-)
 
is there a way to do n!/c mod m?
like
calculating n! mod m as normal
then somehow dividing it by some tweak of c
to get n!/c mod m altogether
 
@JohnSmith not for your range of arguments
 
n^n < n!^2 < n^2n
so with arguments like million you're talking six million digits (rough)
or maybe twice that, i'm not sure
 
12:19 AM
no no
say i have (16!/7) mod 23 = 15.

I want to be able to do 16! mod 23 as normal and get 13
And somehow get from here to =15 using my /7 left over
normally what i would do is calculate the factorial and just exclude 7
e.g. 1*2*3*4*5*6*8*9...
but for memoization this won't work for a dynamic denominator
is there a way to get from 16! mod m to 16!/7 mod m?
 
>>> math.factorial( 16 ) % 23
13L
>>> _
^ Python
 
right
16! mod 23=13
but say I am really trying to solve (16!/7)mod23
 
Python has a nice arbitrary-size integer arithmetic
 
my factorial function right now calculates n! mod m using memoization
 
12:23 AM
yay! I figured it out!
 
@LearningC no
 
1 message moved to bin
 
is it impossible to go from n! mod m to n!/c mod m?
 
@JohnSmith i'd google that. i associate vaguely about relative primes and chinese remainders and whatnot. i'm not sure for the general case
@john maybe one of the super-bright students here know. just HOLLER :-)
 
from what i am seeing
i can multiply by 1/7 mod m i think
 
12:28 AM
looks like it
taking care about that relative prime business of course
 
god this algorithm is cofusing
 
I hate my university and my course so much, it's heartbreaking and beyond my previous imagination
 
If I have a const and non-const overloads of a member function and I want to do the const_cast trick, which one do I do it on?
 
@Pubby The const one.
you do something like const T& func() { return const_cast<U*>(this)->func(); }
 
12:43 AM
@DeadMG what if the non-const one modifies the object? Wouldn't it be safer to do it to the non-const one?
 
then it doesn't really meet the conditions of the const_cast trick
which is when you don't need separate logic in both functions
 
I know, it just seems more foolproof
 
well, it would also be foolproof to have the compiler generate code from the functional specification, but that's never gonna happen either
 
What do you mean?
 
I mean that you're daydreaming about something which is physically not possible
your functions do not qualify for the const_cast, so write them separately
 
12:50 AM
@JohnSmith if euclid's algorithm is confusing, go to the source, Euclid's "Elements" from several hundred years before 0 bc
 
@DeadMG This is what I'm talking about: ideone.com/oRrKL
The top one gives an error, the bottom one doesn't.
 
because you tried to modify the value of a member variable in a const member function?
 
Yeah, I'd rather be safer
 
well, I dunno if you need the memo here, but it's a dumb idea to mutate the object in an accessor.
and if you have some internal implementation detail which makes it not a dumb idea, then use mutable, that's what it's for
 
12:53 AM
That's the point. If for some dumb reason I accidentally mutate it then it doesn't compile.
 
good?
that's what const is for
 
1:10 AM
Can I install clang on my linux machine without it stomping on g++?
 
Dammit I can't commit on Google Code again.
What would you recommend? Bitbucket, github, ...?
 
actually that's a dumb question, it will go to usr/local
I've recently started some stuff on github, it's pretty nice
 
@CollinHockey What do you mean with stomping on g++?
 
like, does clang come with headers that are going to screw up g++
 
I use bitbucket
 
1:13 AM
or install a new libstdc++ or something
 
@CollinHockey No, that's not going to happen.
 
and the fact that I use Bitbucket instead of screaming at it says something
 
@StackedCrooked thanks
 
@DeadMG There's a strong argument.
 
whereas imagine what I'd do on github
 
1:15 AM
never got on bitbucket because I never really used hg, but now they support git too
 
why isnt this working :<
 
With Google Code the commit starts and then suddenly gets interrupted and shows an error message. Meanwhile I have been continuing working on my code and I only notice the error message an hour later or so.
 
Don't use SVN, lol.
Google Code supports Hg, too.
 
The EEA doesnt seem to work wtf
 
@CatPlusPlus Right, I forgot about that.
 
1:18 AM
Bitbucket can import SVN repos, if you want to migrate quickly.
 
Hm...
 
SVN is short for Subversion, right?
 
just figured I'd check
 
> undermine the power and authority of (an established system or institution): an attempt to subvert democratic government.
"undermining" sometimes seems like the appropriate word
 
1:21 AM
undermining who where and the what now?
 
svn is undermining my code.
 
ah
1 message moved to bin
 
whoops, drive by pasting
I wasn't leaving though
 
make it protected instead?
 
that's so unfortunate
my life would be vastly superior if you did
fortunately, though, I do have that ignore list..
 
1:30 AM
@CollinHockey I need it to be non-copyable though
 
take a dead argument with a default? Child(Parent& p, int nonsense = 0);
doesn't seem kosher, but might work
 
@CollinHockey doesn't seem to work
and it's ugly anyway
 
it felt a little dirty
what about marking it explicit? (wild guess)
 
making what explicit?
 
Trying to stay within the 100 chars per line limit and make the code look nice and use descriptive class and method names. Aargh..
 
1:41 AM
that constructor
 
// How should I define the const overload
// for the 'getItems' method?
struct Test
{
    typedef boost::shared_ptr<Item> ItemPtr;
    typedef std::vector<ItemPtr> Items;
    Items getItems();
};
 
const Items getItems() const; ?
Actually you might return a const reference
 
what do you actually need that reference for?
 
@SethCarnegie The problem is that I'm giving away non-const access to the actual 'Item' objects then.
Because boost::shared_ptr gives me non-const access using const accessors.
 
1:45 AM
@SethCarnegie Maybe it's better to have some kind of static initializer that calls a different constructor with the stuff you need from that reference
 
@StackedCrooked You need ConstItemPtr.
(aka boost::shared_ptr<Item const>)
 
I see.
 
@RMartinhoFernandes yea
 
anyone here know about the extended euclidean alg?
 
2:24 AM
Hey, anyone here handy with Big-O?
I'm reading "Introduction to Algorithms" and it's saying "2n = O(n^2)" which doesn't make sense to me (I thought it'd be equal to O(n).)
 
Since Big-Oh is an upper bound, that is technically correct, it's just not a very tight bound
If I had my CLRS book here I'd check the section
It's also equal to O(n)
 
Ah, that makes sense
Thanks :)
 
anyone here know extended euclidean algorithm
 
2:42 AM
I don't, but what are you stuck on? Maybe a good question for CompSci or Mathematics?
 
Als
I have seen the following being Q asked a number of times lately in various formats,
8
Q: What is the difference between char a[] = ?string?; and char *p = ?string?;?

SachinAs the heading says, What is the difference between char a[] = ?string?; and char *p = ?string?; This question was asked to me in interview. I even dont understand the statement. char a[] = ?string? Here what is ? operator? Is it a part of a string or it has some specific meaning?

I am going to mark it as an C++-Faq, If anyone disagrees, please leave me a comment here.
 
With the messed up character sets and all?
I mean, that question is seen with those quite a bit?
 
8
Q: What is the difference between char a[] = ?string?; and char *p = ?string?;?

SachinAs the heading says, What is the difference between char a[] = ?string?; and char *p = ?string?; This question was asked to me in interview. I even dont understand the statement. char a[] = ?string? Here what is ? operator? Is it a part of a string or it has some specific meaning?

 
Als
@CollinHockey: uhm?
 
I mean, are you adding it for the pointer vs array answers or the messed up font confusing people taking these interview tests?
More out of curiosity than anything else
 
Als
2:58 AM
@CollinHockey pointer vs array answer ofcourse.
 
I'm just wondering if there's another Q where the question was more well formed
 
Als
If you find another Q which has better & more authorative answers feel free to bring them formed and we could mark that as an faq.
 
That's the thing, the answers there are excellent
 
Als
@CollinHockey Yes & hence I chose this one, Later We could edit the Q title but that would add some irrelevant comments in the answers, well we could live with that but I will just wait if someone can bring about an Q with better answers so we don't have to edit this one and just mark the other as an faq then.
 
Doesn't bother me really, I see some good C ones, but these answers have some C++ specific notes
 
Als
3:03 AM
@CollinHockey Yes, the answer for this Q will vary for c and c++ , especially the usage of const.
 
3:28 AM
Is there any fast inverse square root for fixed point numbers?
 
 
1 hour later…
4:41 AM
@Pubby x*x
 
@CheersandhthAlf Hehe, I mean multiplicative inverse! Still haven't really found anything, guess I'll use newton-raphson.
 
There's the infamous Quake implementation.
Fast inverse square root (sometimes referred to as Fast InvSqrt() or by the hexadecimal constant 0x5f3759df) is a method of calculating x-½, the reciprocal (or multiplicative inverse) of a square root for a 32-bit floating point number in IEEE 754 floating point format. The algorithm was probably developed at Silicon Graphics in the early 1990s, and an implementation appeared in 1999 in the Quake III Arena source code, but the method did not appear on public forums such as Usenet until 2002 or 2003. At the time, the primary advantage of the algorithm came from avoiding computationally ex...
Beyond the initial WTF it is using Newton-Raphson ;).
 
Well yeah, but that's for floating point
 
Gah! My brain only parses 'point'.
 
I guess I should have written it point-free
 
4:45 AM
In numerical analysis, there are several methods for calculating the principal square root of a nonnegative real number. For the square roots of a negative or complex number, see below. Generally, these methods yield approximate results. To get a higher precision for the root, a higher precision for the square is required and a larger number of steps must be calculated. Rough estimation Many of the methods for calculating square roots of a positive real number S require an initial seed value. If the initial value is too far from the actual square root, the calculation will be slowed do...
^ The section on iterative methods for inverse square roots seems to be relevant.
 
I read through that, but must of passed over that part. Thanks.
 
1
Q: Modern, native way of creating WinAPI GUI apps in C++

B.Gen.Jack.O.Neillfirst I know this is kind of common question around. But, I could not find exact answer I am looking for. So, I have done many projects in Java, using Swing. Starting just coding the gui, moving onto GUI designers. This prooved VERY quick and easy way to build GUI apps. But now, I need to move ...

This is why Boost badly needs a GUI library
 
5:32 AM
^ What does this mean?
This symbol is currently on the Google homepage.
 
So it can mean anything?
> Anarchist Black Ribbon Campaign
I like that.
 
is it ok to give a title of resume/cv "Arts developer"?
 
why?
 
5:36 AM
It sounds presumptuous.
You are a software developer. In my opinion software development is a craft rather than an art.
Art makes me think of Van Gogh, Picasso etc.
 
Trolling is a art.
 
but I mean is it ok with grammar? or is "Art developer" more correct?
 
If your code resembles a Picasso painting then you are probably doing it wrong.
"Arts developer" doesn't sound right from a grammatical perspective as well. Isn't "artist" the word you are looking for?
 
no, artist is artist, but art developer implicitly has a connection with software development
 
5:40 AM
^ one-boxing didn' work. that's link to wikipedia's article on the my lai massacre in vietnam, the mass murder by US soldiers of between 347 and 504 unarmed civilians in south vietnam on march 16, 1968
i would think that that's what google's black ribbon is about
maybe
 
So, finally, "Art developer" or "Arts developer"?
 
@CheersandhthAlf That a large number of killings. Two days ago a Belgian schoolbus crashed and around 20 kids died. Yesterday was declared a day of national mourning. Yet the number of people died is less than 10% of that.
@Acute Artist or juggler. Both are fine.
^ This is where you should ask the question.
 
most of the 400 to 500 people killed in my lai were killed were women and children. one soldier was sentenced and served about 3 years in prison for it.
 
> Three US servicemen who had tried to halt the massacre and protect the wounded were later denounced by several US Congressmen. They received hate mail and death threats and found mutilated animals on their doorsteps.[7] It was 30 years before they were honored for their efforts.
This is depressing.
Please don't post links like this :(
 
Thanks for link, but can you just say: "Art developer" or "Arts developer"? (sorry for annoying)
 
5:44 AM
@Acute I don't know, I'm merely Belgian.
 
oh... ok
thanks anyway
 
I don't see black ribbon on norwegian or us Google pages, so it's possibly only in belgium they remember my lai, possibly due to the bus crash?
 
You will get high quality answers on that site.
@CheersandhthAlf Ah perhaps it is related to the bus crash.
So the ribbon is simply a symbol of mourning?
 
sorry if i wrote offensive things there
i didn't think very much
 
5:47 AM
haven't slept all night in fact
 
@CheersandhthAlf You didn't.
Unless I'm just as blind as you are.
It's 6:47 AM here. I should sleep soon, because I have to get up at 7:15 AM for work.
 
Just kidding, I took a day off on Friday :D
But I did stay up quite late. Have been mostly programming, or rather, tweaking code in order to get prettier results.
^ This makes me feel good :D
Perhaps the album version is better.
Is C++ your favorite programming language?
 
6:14 AM
No.
 
Yours is Factor, right?
 
Haskell, Python.
Factor, too, I guess.
The higher level the better.
 
I experimented a little with Haskell a few years ago. And for some reason I never did any Python.
I guess Haskell is the most high-level then.
My favorite language is currently C++. But I know less about it than most of you guys here. Seems like misinformed love, or something.
 
The worst part of C++ is dealing with tools.
It's just so damn annoying.
 
I would think that languages like Haskell and Factor have even less tools support than C++.
 
6:20 AM
It's not about quantity, it's about quality.
Haskell has pretty much only one compiler, which works well everywhere, plus one build system, plus package manager integrated with that build system.
 
Perhaps the annoying part about C++ is mostly its verbosity. You have to declare stuff in header files and define it in cpp files. It's kind of tiring.
Having more than one choice isn't necessarily a bad thing.
But I get your point.
 
If only the choice wasn't "crappy", "crappy", "more crappy".
Not to mention build systems.
Clang will probably eventually work on Windows, but build systems will still suck.
 
I've used CMake and didn't really find it that problematic. It does have its own syntax that you have to figure out, reluctantly. But in the end it did work for me.
Build systems aren't really a big issue imo.
Or perhaps I've been exposed to pains too much and I've become immune.
 
Or didn't have a project that requires bit more involved build procedure.
Or containing bits in other languages.
 
Currently at work we're using auto tools, which is indeed horrible. (I still don't understand why the m4 files are needed.) When I introduced a SWIG layer in order make our APIs available in Java it was not such a big deal. In the end you don't spend most of your time on the build system.
This probably doesn't sound very encouraging..
This may sound ridiculous, but IMO, the problem with C++ is methods. You can't do anything with them.
 
6:35 AM
M4 is the macro system autotools use to generate stuff.
 
You can't take a class and iterate over its methods.
 
That's reflection.
 
I know a little about the M4 language. But I don't really see its role in automake. (But that's just because of my reluctance to figure it out.)
@CatPlusPlus Indeed. That's what I'm missing most in C++.
So I end up using crutches like the "command pattern" in combination with decorators.
 
I prefer codegen.
 
How? Using boost preprocessor?
 
6:39 AM
That's rather limited.
I'm using cog lately.
 
I'm not really familiar with code generation tools. .. I've heard of cog though.
 
They generate code.
:P
Ideal tool would be something like Template Haskell.
 
Never heard about that.
Well, I can read about it. I'm planning to learn more about Haskell anyway.
 
 
1 hour later…
8:00 AM
Wow, I'd never heard of cog...that looks extremely handy.
 
sbi
@keithlayne It's always nice to see new people starting to like Fforde.
 
Normal conversations shouldn't require google-fu to make sense.
 
sbi
@keithlayne Yeah, but there's nothing normal about conversation in this chat room. :)
Jasper Fforde, in his Thursday Next series, came up with the Council of Genres, abbreviated COG. I love those books.
 
Ha that was obvious :)
 
sbi
@sehe I thought so, too. Scratch that. What are you referring to?
 
8:10 AM
@sbi touché
 
@sbi Your reference to Fforde should have made obvious sense to anyone, not? I mean, who doesn't read books?
 
Americans.
 
sbi
@sehe I think @Tony claims to not to read books.
 
irony :)
 
I don't read many... but even I've read the Thursday Next series :)
 
8:13 AM
@sbi Thanks for that, anyway. Any suggestions on a good Fforde book to check out as a start?
 
I usually remember titles, not authors.
 
@keithlayne I think Lost In a Good Book was the first in the series
no, I fail.. it was The Eyre Affair
 
sbi
@keithlayne The first in the Thursday Next series. As @je4d said, it's The Eyre Affair.
 
yeah, was just checking out Amazon
At the risk of more mockery from @sbi, I'm glad to see Fforde's books are published in electronic format.
 
morning all
@sbi by any chance does your first name start with C? I'm not sure if I saw a post where the robot proclaimed being on of the few (around here) who know you real name or I just had an odd dream
 
8:30 AM
2
A: bit size of int array defined using typedef

refpThe number of bits (and bytes) allocated may vary. Though, it is guaranteed to create a sequentiell storage for 10 integers which can be references through set1. What does the standard say? The standard doesn't force a byte to contain N bits since that will make it harder to write compilers f...

quoting the standard, not always guaranteed to get you vote-ups
and yes people, the annoying little refp is back
 
@refp don't forget that old, int has no fixed sized
 
@thecoshman I believe I wrote that, or did I miss the "edit" button?
 
though with C is it not at least as big as short and at least 4 bytes?
 
Morning! I'm having some diffictulties bith my binary tree - when i try to delete object, it throwst stack overflow after a few seconds. Important parts of my code are below:

class binary_tree
{
public:
binary_tree *father, *left_son, *right_son;
short value;

//some constructors

~binary_tree();
};

binary_tree::~binary_tree()
{
if (this->left_son != NULL) delete this->left_son;
if (this->right_son != NULL) delete this->right_son;
delete this;
};
 
@refp you talked about bits in a bytes, not bytes in a variable
@gogowitczak ideone.com
 
8:35 AM
delete this...
 
@thecoshman "The number of bits (and bytes) allocated may vary."
 
@keithlayne noticed that just as you said it :P that's a new one on me
 
And I'm making objects like:
binary_tree* temp = new binary_tree()
delete temp;
 
Using delete this; in the destructor will end up recursively calling that very destructor.
 
@refp true, but you only mention it in parsing, I would consider the bytes in an int more important then bits in a byte, but only just
 
8:36 AM
you might separate the notion of a tree and a node, or not
 
@LucDanton - thx, I'm a moreon :)
2
 
ideone.com/gKBY7 fixed me thinks
 
@luc you did it again, stealing my chat rep :)
 
@keithlayne I disagree. delete this; is not necessarily incorrect. The important part here is that it was in the destructor.
 
note that I also commented out you use this-> there is no need for it, other the verbosity if you really want it
 
8:39 AM
@luc that was totally implied...in my head
 
@thecoshman added a statement explicitly saying that ints can vary in size cross platform
not that it matters since no one will read that post, but still
 
@refp it still makes the world a better place.
 
I would also suggest smart pointers :D and adding a pointer to the data object rather then have the data as part of the tree, though I understand there are times when you would want that
 
...and parameterizing the class...
 
yeah, well a lot of things could be done
 
sbi
8:43 AM
@thecoshman The robot has indeed found out about my name. However, since I want to keep that private, I will not answer your question.
 
but you just did! Sort of.
 
@sbi I thought you might be of that view, so I shall no more on the matter. Though it would appear that the Robot is leaking information :P
 
@sbi he's right, you may have to revoke Martinho's security clearance
 
@keithlayne I think it is time to perform a fresh install
 
@keithlayne hopefully yeah
 
8:47 AM
"I'm sorry, I can't let you do that, Dave"
 
@keithlayne as long as I keep shut, I am always right :D
 
sbi
@keithlayne There's several users here who know my real name, and I have little problem with that. (Although the robot is the only one who found out for himself.) I just do not want this to be readable to all the world here.
 
@keithlayne silly robot, my name is not Dave
 
@sbi I'm sure it is a temptation for some to try.
 
sbi
@thecoshman He claimed he had found out. I always said I have dropped enough clues to find out if you are really determined. So his statement is nothing new.
 
8:50 AM
There is a fine line between being private and being mysterious...inquisitive minds sometimes can't refuse what seems like a challenge.
 
sbi
@keithlayne Feel free to find out and drop me a mail. All I ask is that you please refrain from publishing what you found.
 
@sbi ah well, It was more that I wasn't sure if I really saw it, or just had one of those dreams where you just do day to day things... I think I might be losing my grip on reality
 
@sbi I wouldn't do that. I think I'd rather respect your privacy.
 
@Als We shouldn't have a FAQ with those nonsense ? characters.
 
8:56 AM
@sbi :O you have a ranting space blog?
 
sbi
@thecoshman If you look at the first thing I published, you can see why I set this up.
 
There Can Be Only One Robot.
 
@sbi oooh, piracy! I thought that said privacy :P was a big confused as I read that
 
@sbi I actually ran across that yesterday.
@sbi There was a comment on that post that made me curious, especially in terms of something you told me a while ago, about something you did as a young man. I think something you said yesterday in the grammar conversation answered my question however.
 

« first day (517 days earlier)      last day (4423 days later) »