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?
Your random number generator might not be able to produce all numbers. Without looking at Math.Random, if it returned an integer then it would never match 0.123456. If it returned a double precision floating point number 0 &lt;= rnd &lt; 1, it might produce a 53 bit integer from 0 to 2^53-1, and multiply by 2^-53. In this case it is quite possible that 0.123456 will never be hit.
But even if 0.123456 would be hit eventually, that random number generator would produce 2^53 possible values. On average it needs to produce 2^52 values before a match. That isn't going to happen within two hours. Assuming 10ns per number, 10ns * 2^52 is about 45 million seconds, or 521 days.