Question:
what is so special about the number 233?
HowToiletsPlay
2013-11-27 23:30:31 UTC
I was running a random number generation program in DOS mode that my friend made, and when I tried to enter the maximum allowable integer for the program, which just so happens to be 9000, as it has an over 9000 integer limit, but my finger slipped without me noticing and I instead entered "9---".

When I pressed enter, the program ran as normal, but there was a missing operand error above every number displayed, and all of the numbers, which are displayed with a gradually diminishing speed to simulate a slot machine wheel and are generated by doing some fancy mathematics with the number you enter and a randomly generated number with a maximum value of 32768 we're all set to the number 233. I tried doing this (an integer followed by three dashes) several times with multiple integers with the same results. It didn't matter if I used only two dashes, or if I used a number greater or less than nine, though when I used only one dash the program glitched and I was forced to terminate it several times before it would finally give up and close, and upon re-opening the program, appending any amount of dashes also resulted in the same glitch. I have gotten the program to repeat the original emergent behavior, but do not recall the conditions that allowed the behavior to be displayed.

I was wondering what could be so special about the number 233 in regards to msDOS and computer programming, and why running that equation (which just so happens to be A = X * H / 32768 + 1 where X is a random integer and H is the input string as well as the maximum integer value of A, which is the resulting random number between 1 and H) constantly results in that number when the input is appended by two or more dashes.
Four answers:
t
2013-11-28 01:04:34 UTC
> I was wondering what could be so special about the number 233



Nothing.



The reason it outputs 233 could be anything from that algorithm's unique behaviour in a certain edge case to the unpredictable value of an uninitialized variable, and cannot be determined without seeing the program's code.



---



True randomness is very rare and computers normally use 'pseudo-random' numbers computed using a mathematical formula. A number called the seed starts off the sequence, and each random number is calculated from the previous one. Using the same value for the seed results in exactly the same sequence of pseudo-random numbers.



Input processing varies across languages, and there are many ways in which format errors can be handled. Sometimes a special value such as -1 or 0 is returned indicate failure, and if the programmer does not explicitly deal with such a value the program will continue to run on invalid data. This can result in undefined behaviour and completely arbitrary output, or the same output again and again because the generator's seed is initialized to the same invalid value.
darrenforster99
2013-11-28 09:09:50 UTC
It will probably be to do with how a computer generates a random number I would guess.



A computer can't actually generate a random number - think about how you create a random number, to generate something random you'd need some kind of personality to pick a number at random.



To generate a "random" set of numbers, a computer uses a seed number - this is why before doing any random function you need to call a randomize function (in C++ it's called srand, some other languages call it randomize) and give it a seed number to use as it's mathematical basis for generating a set of floating point values between 0 and 1 (it always generates random numbers between 0 and 1 and then multiplies it by the range you need - for example if you wanted a random number between 0-10 it might produce the number 0.5 and then times it by ten which would give you 5, 10-20 would be 0.5 * 10 (range 10-20 = 10) + 10 (start of range is 10) which would give 15)



Of course the sequence of the numbers all depends on what you are initially using as a random seed. Normally you would use something like the system time/date variable as this is constantly progressing and therefore won't be the same again (even the same time tomorrow will be a different date) and so that way you'll always get a "random" combination, even though the random function is mathematically decided.



If using a date/time on a PC you wouldn't really notice the random seed in operation as it would change so widely, but on some cheap CD players when you stick them on random you can sometimes see the random seed in operation, as most cheap CD players don't have any proper way to know the time and date, so just use the number of processor ticks to generate the random function (or just use track length or something), and so you might notice that even when you stick random on a CD player it always plays the same songs in the same random order because it's using the same seed number every time.



Now this with this random number you have found here - firstly what are you initializing your random numbers with - have you got something somewhere like an srand function



http://www.cplusplus.com/reference/cstdlib/srand/



If not then that is why you are getting the same number over and over again, call the srand function with something like

srand ( time ( NULL ) ) ;

and you might notice a major difference.



Also are you using the same value for srand every time



srand ( 9 ) ;

should give the same combination of random numbers every time, as long as nothing else interferes with it.



Finally it could be that the -- are unexpected by C++ and C++ has a tendency to try and utilise in funny ways what ever is unexpected. Something like BASIC would stop and complain that there is something wrong, C++ is more like ok it's not right data but I'll carry on regardless and try and utilise this rubbish data in some other way (I remember finding that one out with cin years ago and the space bar - cin sees a space as a CR character for some strange reason and so anything after a space is pressed is used for the next cin!). It's up to the programmer to notice these problem - C++ isn't going to baby you like BASIC does!



So it could be putting this invalid data anywhere and is most probably interfering with the random function area of the memory in some way.
2013-11-28 07:33:33 UTC
it's the god number
2013-11-28 07:30:58 UTC
o.O


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...