« first day (662 days earlier)      last day (4293 days later) » 

8:00 PM
There is an amount of porn, sci-fi, drama, humour, and animation in every movie
 
@JerryCoffin You could make a drinking game for suicidal people out of this.
 
@EtiennedeMartel (I was slightly.)
 
Wait, there is a PHP spec?
3
 
@EtiennedeMartel Good idea. After reading the PHP spec, anybody would think they were pretty awesome.
 
@R.MartinhoFernandes No, he said "doc" I think
 
@R.MartinhoFernandes Voting to close as exact duplicate.
3
Q: PHP language specification?

RolfI know there is an official document for Java (JLS), I'd like to know if it's also the case of PHP language. I found the "Language Reference" section on the PHP manual, but it doesn't look as detailed as the JLS. The thing is I have a good practical knowledge of PHP but I'm miserably clueless a...

 
It's impossible for PHP to have a spec. It's not planned out, it just happens.
 
@Drise Quite a few languages like that still get specs (of some sort or other) after it happens. In fact, C and C++ both did that to varying degrees. Granted, there was a lot more forethought put into a single feature of either than into all of PHP put together, but they've still both evolved well ahead of any comprehensive spec at times.
 
3
Q: What is the probability that the array will remain the same?

AashishThis question has been asked in Microsoft interview.Very much curious to know why these people ask so strange questions on probability. Given a rand(N), a random generator which generates random number from 0 to N-1. int A[N]; // An array of size N for(i = 0; i < N; i++) { int m = rand(N...

 
2
A: PHP language specification?

Jimmy RFrom what I read on Wikipedia, both PHP and Perl5 have in common that they are "languages" which are entirely defined through one single implementation. The language is precisely whatever the interpreter does. Neither are like C or C++ or Java or ECMAScript, which are standardised languages with ...

 
8:08 PM
Maybe I'm reading between the lines, but if swap() is not a macro, then the answer is 1 or UB?
 
Wasn't there a PHP implementation for the CLR?
 
Phalanger.
 
Yeah, that.
I wonder if it's any good.
 
@Mysticial 1.
 
@EtiennedeMartel Unless it's really not an implementation of PHP, how could it possibly be good?
 
8:12 PM
@JerryCoffin Excellent question.
 
@R.MartinhoFernandes Couldn't you just have swap(int& a, int& b)?
 
@Collin Not in C.
 
@Collin It's tagged C, not C++.
 
Oh, missed that tag
 
@Mysticial Oh yeah, UB because it's not initialised.
 
8:17 PM
@R.MartinhoFernandes I believe theres enough implication that the array is initialized to unique elements, but it should probably be noted as an assumption.
 
@MooingDuck Ah, ok.
They're asking this question because they don't want this thing to happen again. — R. Martinho Fernandes 13 secs ago
 
Aargh!
3
A: Is it a memory leak?

Konrad RudolphYou need to understand that memory leaks are not about pointers (really: never – even though a lot of people will claim something different). The whole business with pointers is just misleading. They are about a mismatch in dynamic memory allocations and deallocations. Every allocation via new...

read the comments
 
@KonradRudolph wow...
 
@KonradRudolph What a mess.
 
And that's why the mods hate us.
 
8:24 PM
@Mysticial I don’t want that stupid discussion
 
@KonradRudolph That's exactly how I'd feel.
 
@KonradRudolph That Alex person is confusing
 
But I got the joke, if you want to dissect.
 
@MooingDuck And in addition, totally oblivious to this, and being a smug dick to top it off
You guys are ridiculously arguing on something so trivial. Be amazed as how I'm being the more mature one and quit this. — Alex Belanger 1 min ago
 
@KonradRudolph huh. whatever. let it go.
 
8:27 PM
@MooingDuck He can't. It keeps popping up on his inbox since it's his answer.
 
@MooingDuck I never argued with that guy.
(I think … apparently he thinks differently)
 
I'd like to tag him as rude and offensive.
 
@SamDeHaan I did.
 
I didn’t. He exposes himself as ridiculous, that’s only offensive to himself.
 
@KonradRudolph I flagged as not constructive actually. I don't care much about comment flag reasons, since they don't really matter.
 
8:32 PM
@KonradRudolph I thought about answering this one, but somehow thought it would go about like it did. The OP has so little concept of what he's dealing with that there's virtually no chance of really helping him, and near certainty of headaches from idiots.
 
Sometimes I wish there was a comment flag reason for "I want these idiots to stop arguing irrelevant crap under my answer."
 
Ok, so how do you convert a std::string toUpper? Someone here showed me with C++11
 
jQuery
 
Boost
 
Converting a string toUpper is quite complex.
 
8:35 PM
Jun 8 at 17:17, by Mooing Duck
@Drise std::transform(str.begin(), str.end(), toupper)
 
@JerryCoffin That’s why I hoped to counter-act the whole pointer nonsense actually, get him before he’s been damaged by misleading talk. Maybe not an achievable aim.
@R.MartinhoFernandes No language/library I know handles “ß” correctly
 
@Drise Doesn't account for "ß" => "SS".
 
@Mysticial who is that on your avatar picture? :o
 
@KonradRudolph Ogonek will :P
 
@Drise only handles ASCII
 
8:36 PM
I have that in mind as a future test case.
 
@R.MartinhoFernandes I only care for ascii
 
You're evil.
:P
 
If you don’t use UTF-8, you suck.
 
@KonradRudolph What we need is to put up that street analogy of pointers and make it a C/C++faq. But it would most certainly be closed as a dupe of everything.
 
@RadekSlupik Fuck UTF-8.
 
8:37 PM
Fuck anything not UTF-8.
 
@Papergay Rio from Sora no Woto
 
Xeo
@Drise "no function found which takes an argument list of (string_iterator, string_iterator, char (*)(char))" :P
 
@RadekSlupik It's irrelevant everywhere except when transmitting data.
 
@R.MartinhoFernandes UTF-8 is nice.
 
i see
 
8:38 PM
@R.MartinhoFernandes Using it everywhere saves the hassle of converting it every time you need to transmit it.
 
@Xeo forgot an include?
 
Xeo
@MooingDuck There's no 3 argument std::transform
You're missing the output iterator
 
whoooops
 
@RadekSlupik Except when you need to transform it for something else. It also makes many things harder to handle.
 
That’s why everything should use UTF-8 everywhere.
From the damn beginning.
 
8:40 PM
@KonradRudolph Maybe achievable, but certainly difficult.
 
@RadekSlupik Well, you're late.
 
I know.
 
As I said earlier, I live in the present.
 
No, you live in the future.
 
Also, the KJV Bible is a whopping 4MB large, so why do care so much about storage space?
 
8:42 PM
lol
 
@R.MartinhoFernandes Because I don't care much about the KJV?
 
> You can disagree as much as you want, but during this talk, by definition anyone who disagrees with me is wrong, stupid, brain damaged and butt-ugly. — Linus Torvalds
 
@JerryCoffin It's the largest book I could think of and get a measure of its size. I picked it to have an idea of how much is "a big amount of text".
 
has anyone here ever created a Firefox extension using C++/XPCOM?
 
8:44 PM
@JerryCoffin That resource is dated just June 2005. I'd expect to be way bigger now
 
@R.MartinhoFernandes I think I have quite a few bigger books. But! I have the Vulgata+KJV on my android phone :)
 
@JerryCoffin Yes, but I don't see many applications needing to deal with that much text. Plus, the Library of Congress is not just text.
 
@DeadMG Undoubtedly larger -- but when it's a couple hundred years old, I wouldn't expect a huge percentage increase in only 7 more years.
 
@JerryCoffin Thank proprietary document formats?
 
@R.MartinhoFernandes All quite true -- in fact, a large part of that is based on scans of the pages instead of looking at text at all.
 
8:46 PM
What about the stuff that's in Project Gutemberg?
 
@JerryCoffin Except the last few years are the Information Age and the library of Congress is going to suck Moore's Law like everyone else.
 
@EtiennedeMartel There's where I got my numbers for the KJV bible.
 
@MooingDuck Yea, we found that problem. Now it's giving us something about bernoli_distribution error?
 
FWIW, I'm not arguing against the existence or use of UTF-8. I'm arguing against the idea that everyone should use UTF-8 everywhere. What happened to the "use the best tool for the job" thing?
 
std::transform(str.begin(), str.end(), str.begin(), ::toupper);
 
8:47 PM
7
Q: Random number generation in C++11 , how to generate , how they work?

user72424I recently came across new way to generate random numbers in C++11 but couldn't digest the papers that I read about it (what is that engine, maths term like distribution, "where all integers produced are equally likely"). So can anyone please explain what are they, what does they mean , how to ...

@Drise not when converting to uppercase, no bernoli there.
 
Yea, the std::transform code is the problem...
I don't understand...
 
@Drise what's the problem? Compiler error? Whats the full compiler error?
 
It's not on my machine.
I'm doing this from memory.
 
@MooingDuck Fucking RNGs, how do they work?!
 
> Assuming "library of congress" is a movie
WTF Wolfram Alpha? Are you nuts?
 
8:50 PM
it had to do something with std::bernoli_distribution or something.
 
bernoulli.
 
@Drise no, I promise it didn't :D
 
@R.MartinhoFernandes No, just stupid.
 
@KonradRudolph magic
 
> Development of this topic is under investigation...
Great.
 
8:52 PM
@MooingDuck I think "or something" probably covers it ("It had to do something with... something" seems fairly general).
 
Not to be confused with the Fairy general.
 
@R.MartinhoFernandes UTF-8's biggest strength remains backward compatibility with ASCII.
 
@EtiennedeMartel Wait, wasn't the point to use UTF-8 everywhere? That would make ASCII irrelevant.
 
@R.MartinhoFernandes Legacy, man, legacy.
 
Still, that only means "use UTF-8 when you want to also handle ASCII easily".
And that's exactly why I want ogonek text to hide the encoding crap: it's as relevant as endianness when dealing with integers.
 
9:08 PM
If you need to program something to happen with P = 0.02 ( I'm assuming that's 2%? ) how would you make sure that event happened 2% of the time? Assuming random() returns an even distribution, would you simply do if ( random( 100 ) == 2 ) make the event happen?
 
That's 1%.
(assuming "even distribution" actually means "uniform distribution")
 
P = = 0.02 is 1%?
 
@Chimera No, but random(100) == 2 should happen about 1% of the time. You probably want random(100) <= 2 instead.
 
Oh duh... got it....
Only 1% chance for a number to appear... so I need to check for <=2 for two percent.
 
9:12 PM
you'll want 1-100 for that.
 
If random(100) returns values in [1, 100]. If it's values in [0, 100) then you want < 2.
 
remember that 0-100 is actually 101 numbers.
so you'd actually be talking about 2/101 if you did <2.
 
ok thanks... I got it. Surprisingly I've never had to do such a thing before.
 
@DeadMG I feel like a <3 joke goes here, but I can't think of a good one
 
@MooingDuck <3 ?
 
9:17 PM
Love.
Bacon >= 3, because Love <3 and bacon > love.
 
So it should be something like : if ( random() % 100 <= 2 ) { // do someting - two percent just hit } ?
 
no, <2
 
And random()%100 is likely to give a non-uniform distribution (depends on what random() is).
 
Standard C-Library random() function.
 
Then I am right.
 
9:19 PM
random() % 100 only gives a guaranteed uniform distribution if RAND_MAX is a multiple of 100, -1.
 
If you really care about the accuracy of those 2%, then you need something smarter.
If "about 2%" is good enough, then by all means proceed, with <2.
 
Yeah I'm thinking "about 2%" is good enough. But just for my edification, how would you get more accurate?
if ( random() / RAND_MAX < 2 ) ?
 
Nah, that'd be zero most of the time, and one rarely; in the end, it'd be always <2.
The C++11 random number facilities make it easy.
I know a post that explains how to get an uniform distribution out of the C library, but I'll need to look it up to find a link.
 
Hmmm so if ( part over the whole is the percentage ) wouldn't random()/RAND_MAX return .02 about 2% of the time?
 
@Chimera But random()/RAND_MAX doesn't return 0.02: it's integer division.
 
9:23 PM
Clearly I'm not a mathemetician
 
@Chimera about. and <.02
 
ugh, so I'm thinking of some random function that returns a float between 0 and 1
 
thanks for the link. Having a look see now.
int r = rand() / ( RAND_MAX / N + 1 ); <--- ah I was on to something with suggesting a division by RAND_MAX
 
Also, who starred my wrong deduction about the value of bacon?
 
9:31 PM
2
A: How to generate random number within range (-x,x)

Jerry Coffin// return a random number between 0 and limit inclusive. int rand_lim(int limit) { int divisor = RAND_MAX/(limit+1); int retval; do { retval = rand() / divisor; } while (retval > limit); return retval; } // Return a random number between lower and upper inclusi...

 
I didn't
 
@JerryCoffin Yeah, looping is the safe bet.
 
Xeo
<3 <random>
 
If love is zero, bacon can be one.
 
Test 123 from dolphin browser
And ohai
 
9:41 PM
@sehe Hello.
 
:)
 
@JerryCoffin hows it handle negatives? rand_lim(-2, -1), rand_lim(-2, 2), rand_lim(-1, -2) and similar?
 
@MooingDuck the upper and lower overload takes the absolute value of the difference between them. So the value passed to the single argument version is always positive. Then when you add back in the negative lower number, it shifts the result back into the desired range.
 
9:57 PM
@Tocs so you're telling me it fails for that last one?
 
(-1,-2] is not a valid range.
erm [-1,-2)
So would you expect it to succeed?
 
rand_lim(-1, -2) has "upper" that's less than "lower" -- that's not a valid range.
 
@Tocs why not? It's not ambiguous. And there's no compiler error or warning.
To be clear: I was trying to figure out if that was valid or not for your function. "not valid" is acceptable.
 
@MooingDuck [-1,-2) is impossible mathematical range, -1 > -2 you can't list integers greater than -1 and less than -2, you're passing nonsense. Handling it as an error is something else. I would probably throw in an assert so you catch it at debug builds, but then not care for release
You could make a templated version, and static_assert at compile time, but you lose the ability to specify the range at runtime
 
1
Q: C++ global namespace access from within another namespace

user643722In the C++ code below, foobar is defined first for a single double parameter, and then again for a single parameter of type Foo. Both are defined within the global namespace. Within the one namespace, a further overload of foobar is defined, with a single parameter of type Bar. From this version...

^ Good question. It seems to be some quirk of the lookup rules.
Oh, ADL!
Still good question!
 
10:08 PM
@Cheersandhth.-Alf how strange, I thought lookup (not ADL) would also check "super" namespaces.
 
@Cheersandhth.-Alf cool
 
Xeo
And unqualified name lookup stops as soon as it finds a matching name. — Xeo 2 mins ago
 
I love ØMQ.
 
@Xeo huh
 
@JamesMcNellis Have you tried ^H on your browser?
@sbi since I'm an Opera user that^ would instantaneously hide my browser (into the tray)
 
Xeo
10:11 PM
@MooingDuck what "huh"?
 
@Xeo I don't understand how that is compatible with the next to last call working?
 
Since I’m a Mac user, that would instantaneously just work.
 
Xeo
@Cheersandhth.-Alf ADL
 
@MooingDuck Prevents really strange results. Consider something like:
int main() {
int i;
// ...
i = 0.0;
return 0;
}
 
Xeo
Since f is of class type, ADL is used in addition to unqualified lookup
double is not, so only unqualified name lookup is done
 
10:12 PM
Now add double i; outside of main. If it kept looking for the best fit, suddenly your assignment would be to ::i instead of the i defined inside main...
 
Modules should have been the number one priority for C++11.
 
Xeo
unqualified name lookup is a strange thing anyways, since it special cases functions in one way (ADL, overload sets, etc), but not in another, like
 
Can’t wait till tomorrow evening.
I want to work on my chat protocol and server.
 
Xeo
10:15 PM
void f(int){}
void g(){ float f; f(42); }
 
And the client library in C. :(
 
Xeo
(a bit contrived example, I have to admit)
 
40% is string handling and the rest is networking. Yes, good job for C.
C-strings are so hilarious.
 
@RadekSlupik I can think of other words I'd use to describe them...
 
Fucked up, moronic, a cancer?
 
Xeo
10:18 PM
They wouldn't be as bad if they wouldn't decay at the drop of a hat...
the literals, I mean
 
They wouldn't be as bad if they had O(1) length lookup.
strlen is the biggest joke since I stole your nose.
 
Xeo
thinking about pascal strings?
 
That would be reasonable.
 
@Xeo or bstrings, or std::string, or java strings, or virtually every other strings
 
Xeo
@MooingDuck Right, in C.
 
10:20 PM
Or, even better, struct string { char* s; size_t len; };
 
Xeo
With no encapsulation, and no genericity
@RadekSlupik Can't hold string literals
 
Luckily, I only have to do some networking with ØMQ and I need to split strings by spaces.
@Xeo why not.
 
Xeo
char*
 
The language could have been designed that every string literal is an instance of struct string.
 
Xeo
hm, constant strings would be impossible then
 
10:21 PM
Maybe with a sigil or a letter or something if you really want char const*.
Or the other way around. Whatever. C has few uses.
 
Xeo
without ctors and conversion for structs, that would be hard. Without a lot of compiler voodoo, anyways
 
You can use C++ almost anywhere you can use C.
Does C have a function not strtok for splitting strings? Not a problem to write it myself, but just wondering.
 
3
Q: Is there a difference between with braces or without when using extern "C"?

user315052So, while being schooled by James Kanze and Loki Astari about C linkage, I was wondering about this: extern "C" int foo1 (void (*)()); extern "C" { int foo2 (void (*)()); } After my schooling, I think it must be that foo1 only takes a function pointer with C++ linkage, while foo2 only takes a ...

 
oh. excellent. Our code is casting const char* to HFILE and back everywhere.
 
Xeo
Right, that's why I'm eagerly waiting for array_ref and string_ref
@RadekSlupik I don't think so
 
10:24 PM
Hmm. I also need to pass data from one thread to another in Haskell. Not sure if that’s easy.
 
you guys do recall that in C++ string literals do contain their length right?
 
Xeo
But I know shit about C except that it sucks quite hard
 
@RadekSlupik That's the only one really designed for the job.
 
My chat protocol uses two sockets. xD
 
Xeo
@MooingDuck We do, but having them hard-coded in their type makes some trouble
 
10:24 PM
oh right, you're doing C.
 
@Jerry then I'll write it myself. It must be thread-safe.
Asynchronous I/O. <3
 
@Xeo so make a simplstring struct that's what Radek suggested, and convert them to that if you want to pass them around.
 
@RadekSlupik If you're using gcc, there's also strtok_r, which is at least thread safe. Still ugly but not quite as ugly.
 
@RadekSlupik There's the reentrant strtok_r version. AFAIK, not standard C, posix maybe
 
strtok is easy as fuck to implement. At least my usecase. I need to split one string into four substrings by spaces.
Probably a few thousand per second, but that doesn't matter. The strings are fairly small.
 
10:27 PM
@RadekSlupik if it's that specific, write a function that returns a struct with four pointers. Instant thread-safe.
 
"1234 1234 daknok Hello, world!" => "1234", "1234", "daknok", "Hello, world!"
Easy to implement. Just a for loop and some variables.
 
Why do you need it thread-safe?
 
@RMartinhoFernandes it will be done from several threads.
I have two async sockets from which I read data. Both need to split strings.
 
What are you doing again?
 
Chat server and client.
One socket is dedicated solely to receiving messages, the other one is for communication with the server (e.g. sending messages, joining rooms, etc).
 
10:31 PM
Use boost?
 
@R.MartinhoFernandes With that looping, is the time to generate the random number going to be long?
 
@RMartinhoFernandes I use ØMQ.
And Boost is not available in C.
 
Or will it more or less be constant based on the range?
 
It's not constant.
 
// return a proper random number that uses the uniform distribution
// of numbers returned by random() -- this is far better than
// simply doing random() % limit
int random_lim(int limit)
{
    int divisor = RAND_MAX/(limit+1);
    int retval;

    do
    {
    	retval = random() / divisor;
    }while (retval > limit);

    return retval;
}
If my range is 0 to 18 I'm worried this is going to spend a lot of time looping calling random()
 
10:33 PM
arc4random_uniform
 
@RadekSlupik What? Why are you using C?
@Chimera No, it shouldn't take many calls to random.
I lack the stats to do a proper calculation, but it should not do more than a couple of calls.
 
@R.MartinhoFernandes Ok and that's because of the uniformity of the distribution returned?
 
@RMartinhoFernandes Because I need to use C. That's what the tech spec says.
 
Basically you pay for the accuracy with speed.
 
But it won't be really a problem writing it in C.
 
10:36 PM
I'll instrument the code and see how many iterations on average it takes. But it doesn't seem noticeable in human time.
 
hey guys, do you know a refrence or book of java that explain the hidding stuff, all books that im reading they just tell what the things do, but no how...
 
Only encryption/decryption is somewhat difficult (but I'm sure there is an implementation of AES-256) and string handling (though I only really need split() and concat()).
 
@R.MartinhoFernandes actually, I think that algorithm does if the range is large
 
@nEAnnam do we look like we READ JAVA BOOKS??!!
 
As I understand it, the body of the loop always gives a value in [0, limit+1], and discards all results equal to limit+1.
 
10:38 PM
idk, maybe you know, dont you?
 
No.
I don't.
 
The resulting distribution is uniform because the "excess" of RAND_MAX over a multiple of limit is discarded that way.
 
I use superior languages whenever possible.
 
@R.MartinhoFernandes Weird, it seems to only ever require one call to random()
 
@RadekSlupik Like C.
 
10:39 PM
@Chimera no wait, I did the math wrong. In the worst case (range of 32769+), it will loop an average of 1.5x (if RAND_MAX is 65536 like Windows).
 
C > Java
 
Not alphabetically.
 
@Chimera depends on the range, but most of the time it should only make one call, yes.
 
@Chimera It only takes more than one about 1/(limit+1) times (not exactly, because of the non-uniformity)
 
yeah, but im a school, i need to learn it :(, i love c, thats why i want a more technical reference...
 
10:40 PM
@MooingDuck No, much less.
 
Thanks all.... I'm not a math genious... this has been enlightening.
 
@RadekSlupik Not really.
 
Java is like “I’m dumb I need protection for anything” and C is like “I’m smart enough to not dereference this fucking pointer because I just free’d it.”
 
@RadekSlupik Java is more expressive than C.
 
@R.MartinhoFernandes I think it's more actually
 
10:40 PM
Heresy!!
 
@MooingDuck 1/(32769) is less than 0.5.
 
Java is more expressive than yo momma. Now that's expressive!
 
@Chimera yeah, if limit is 32769, it will repeat ~50% of the time, for an average of... I dunno. 1.5+.25+.125+0125...
 
@MooingDuck No.
If the limit is that, the divisor will be 1, right?
 
Well just running the code, I've not seen it take more than one call to random() yet.
 
10:42 PM
@R.MartinhoFernandes right
 
Then the random number generated in each loop iteration will be exactly between 0 and RAND_MAX.
 
@R.MartinhoFernandes on windows thats 65536
@Chimera if limit is small, then that's normal. For certain (large) limits, it might average 2x random calls. I think. RMartinho disagrees.
 
@MooingDuck Excellent... yeah my range is only 0 to 18
 
It repeats each time that number is larger than 32769, which is less than half.
 
@R.MartinhoFernandes barely, yes
 
10:44 PM
java have alot of hidding stuff, i dont know how the things works, i need kind of 'low level' orientation, so no one knows a good reference?
 
Anyway, 0.5+0.25+0.125+0.0625+... is 1.
 
Meh hiding information. It's like censorship.
 
@Chimera should repeat 2+ times about 0.0244141% of the time at that range
 
@nEAnnam Forget the Java then.
 
Therefore Java == China
 
10:46 PM
@R.MartinhoFernandes of a repeat. Plus 1 for the origional rand call.
 
school :(
 
@R.MartinhoFernandes 1.5+.25+.125+0125... total rand calls
 
@nEAnnam Then you don't need the low-level stuff.
 
I rarely ever felt the need to really hide any data. Usually only when wrapping libraries or similar things.
 
@MooingDuck Yes, I was just giving you the result of that infinite sum.
 
10:46 PM
@R.MartinhoFernandes which is 2. when you include the origional call.
 
Handles and stuff.
 
Well again, I appreciate the help -- statistics and math, not be strong area
 
@MooingDuck Sure, but I started with 0.5!
 
I'm a good mechanic, but I probably couldn't design the car.
 
Knowing the low-level stuff is worthless to learn Java.
 
10:47 PM
oh looking at my origional message, I worded it poorly. I worded it wrong.
 
I would download a car.
 
@Chimera for the worst case (limit=32769 on windows), it will call rand an average of twice.
limit= 2147483647 for GCC.
 
I think you misclicked.
 
@MooingDuck Yeah, I've yet to see random() called more than once. So I'm not worried about the speed of execution any longer.
 
@Chimera yeah. Odds of looping even five times are immensely tiny.
@Chimera are you on GCC or MSVC?
 
10:51 PM
@MooingDuck GCC
Right now I'm reseeding from /dev/urandom every 10th call to random(). That is probably not necessary given the length of the sequence right?
 
@Chimera on GCC, with limit=19, odds of calling random twice is about 000000139698%. three times is... virtually never.
@Chimera you shouldn't need to reseed ever. I only reseed if I want to duplicate results.
 
@Chimera Reseeding is rarely ever needed.
 
Ok I will remove that code then... I wasn't sure...
In fact, it appears I'm getting better pseudo random number by not reseeding.
 
@Chimera right
 
I suppose the sequence of numbers for any given seed is very long.
 
10:57 PM
Reseeding starts a new distribution.
 
@Chimera by my math, if you call the function 1000000 a second, you would expect it to call rand() 3 times about once every 1.62 years. (limit=19, RAND_MAX=2^32)
 
As a clear proof, if you reseeded every time, your distribution would not be uniform, it would be the distribution of the seeds.
 
@MooingDuck LOL...
@MooingDuck Then this looping function is quite adequate. :-)
 
@Chimera right, the looping is effectively an emergency backup if it can't get the picked number 100% evenly distributed.
 

« first day (662 days earlier)      last day (4293 days later) »