Click here to Skip to main content
15,888,286 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
BryanFazekas27-Apr-20 1:10
BryanFazekas27-Apr-20 1:10 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
raddevus27-Apr-20 3:20
mvaraddevus27-Apr-20 3:20 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
raddevus27-Apr-20 3:32
mvaraddevus27-Apr-20 3:32 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
raddevus27-Apr-20 5:59
mvaraddevus27-Apr-20 5:59 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
BryanFazekas27-Apr-20 7:18
BryanFazekas27-Apr-20 7:18 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
ElectronProgrammer29-Apr-20 9:32
ElectronProgrammer29-Apr-20 9:32 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
raddevus29-Apr-20 10:53
mvaraddevus29-Apr-20 10:53 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
ElectronProgrammer29-Apr-20 12:17
ElectronProgrammer29-Apr-20 12:17 
The first time I used random numbers in C, in my first programming class in university, I went through the same questions just to realize that certain numbers are simply not in the sequence generated by the pseudo-random number generator. In your example it is zero but you can probably pick any other number and the same will happen. If javascript does not automatically reseed you will have always the same sequence and never have the number you want.

Later, in university, I studied how pseudo random number generators were constructed in silicon and understood why certain numbers never show up using a certain seed. If I recall correctly (as it was two decades ago), the seed must be one that triggers the maximum length sequence of the generator and most seeds do not. If you search for "pseudo random generator logic gates" or something similar you probably find information about it if you are interested.

Curiously, I trashed yesterday one of the Springer publications from 2007 that shows up in the results D'Oh! | :doh:

I am sorry if I sounded too aggressive about the floating point counter. Usually a "while(1)" is used for boundless loops. When I saw it I thought you were using it without knowing. Unfortunately, I already had my share of people "asking" me to fix their programs that do not stop because of loop conditions that are never met (like using integers with double/boolean/string/pointers/etc).

Best regards and keep the curiosity high Smile | :)
GeneralCryptic Error Time: Favorite Part of Your Day Pin
raddevus6-Apr-20 9:57
mvaraddevus6-Apr-20 9:57 
GeneralRe: Cryptic Error Time: Favorite Part of Your Day Pin
Greg Utas6-Apr-20 10:08
professionalGreg Utas6-Apr-20 10:08 
GeneralRe: Cryptic Error Time: Favorite Part of Your Day Pin
raddevus6-Apr-20 10:09
mvaraddevus6-Apr-20 10:09 
GeneralRe: Cryptic Error Time: Favorite Part of Your Day Pin
Slow Eddie8-Apr-20 2:56
professionalSlow Eddie8-Apr-20 2:56 
GeneralRe: Cryptic Error Time: Favorite Part of Your Day Pin
Richard Deeming7-Apr-20 1:03
mveRichard Deeming7-Apr-20 1:03 
GeneralRe: Cryptic Error Time: Favorite Part of Your Day Pin
raddevus7-Apr-20 2:21
mvaraddevus7-Apr-20 2:21 
GeneralGriff and 10gb update Pin
Afzaal Ahmad Zeeshan29-Mar-20 12:22
professionalAfzaal Ahmad Zeeshan29-Mar-20 12:22 
GeneralRe: Griff and 10gb update Pin
Super Lloyd29-Mar-20 12:58
Super Lloyd29-Mar-20 12:58 
GeneralRe: Griff and 10gb update Pin
Afzaal Ahmad Zeeshan29-Mar-20 21:51
professionalAfzaal Ahmad Zeeshan29-Mar-20 21:51 
GeneralRe: Griff and 10gb update Pin
OriginalGriff29-Mar-20 22:36
mveOriginalGriff29-Mar-20 22:36 
RantWhen Poor Design Gets Baked Into a File Format Pin
Kevin Li (Li, Ken-un)29-Mar-20 6:30
Kevin Li (Li, Ken-un)29-Mar-20 6:30 
GeneralRe: When Poor Design Gets Baked Into a File Format Pin
phil.o29-Mar-20 6:45
professionalphil.o29-Mar-20 6:45 
GeneralRe: When Poor Design Gets Baked Into a File Format Pin
Super Lloyd29-Mar-20 13:48
Super Lloyd29-Mar-20 13:48 
GeneralRe: When Poor Design Gets Baked Into a File Format Pin
honey the codewitch29-Mar-20 7:28
mvahoney the codewitch29-Mar-20 7:28 
GeneralRe: When Poor Design Gets Baked Into a File Format Pin
Greg Utas29-Mar-20 8:24
professionalGreg Utas29-Mar-20 8:24 
GeneralRe: When Poor Design Gets Baked Into a File Format Pin
honey the codewitch29-Mar-20 9:24
mvahoney the codewitch29-Mar-20 9:24 
GeneralRe: When Poor Design Gets Baked Into a File Format Pin
Greg Utas29-Mar-20 9:40
professionalGreg Utas29-Mar-20 9:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.