# Will random function ever hit a hard coded decimal number?

I'm not very sure how exactly a fractal number is stored nor how random function works in mordern programming languages.

But I am curious, will random function ever hits a hard coded decimal number?

I know mathematically it is impossible, but how about in computer science?

Such as the following javascript code, will it ever hit the number and stop?

// this can be any number
const rnd = 0.123456;

while (true) {
if(rnd === Math.random()) {
console.log('hit');
break;
}
}


Also I ran that code for 2 hours and it didn't stop

If decimal points are store in 64 bit, does that mean the chance to hit any decimal point is 1/2^64?

If it can hit, is 0.000123456 harder to hit than 0.01?

Well, it technically is possible (with a small caveat). This is due to the fact a computer has finite memory, and hence cannot represent all possible numbers, but rather only a very very small fraction of them (and thus the probability to "hit" some particular number it can represent is not 0). However, it still depends on the random function's behavior. For example (an example I totally made up, just for the point), if the random function will always return a value with only 4 digits after the decimal dot, then it can't return 0.123456. This can happen for a lot of reasons, not only if it returns a value with only 4 digits after the decimal point (which was a made up restriction).
So it is possible to hit numbers like that, maybe not 0.123456 specifically, but some other numbers.
Anyways, the computer can still represent a lot of numbers. Depending on your computer, it can be around $$2^{32}$$ different numbers, hence, if you try to actually run this code on your computer, it could take a lot of time and you might even start to think it will never finish...