i tried Math.random(), but that gave a rational number. i'm very lucky i guess?
i tried Math.random(), but that gave a rational number. i'm very lucky i guess?
It's true that no matter what symbolic representation format you choose (binary or otherwise) it will never be able to encode all irrational numbers, because there are uncountably many of them.
But it's certainly false that computers can only represent rational numbers. Sure, there are certain conventional formats that can only represent rational numbers (e.g. IEEE-754 floating point) but it's easy to come up with other formats that can represent irrationals as well. For instance, the Unicode string "√5" is representable as 4 UTF-8 bytes and unambiguously denotes a particular irrational.
> representable in a finite number of digits or bits
Implying a digit-based representation.
As the other person pointed out, this is representing an irrational number unambiguously in a finite number of bits (8 bits in a byte). I fail to see how your original statement was careful :)
> representable in a finite number of digits or bits
I can define sqrt(5) in a hard-coded table on a maths program using a few bytes, as well as all the rules for manipulating it in order to end up with correct results.
Of course if you know that you want the square root of five a priori then you can store it in zero bits in the representation where everything represents the square root of five. Bits in memory always represent a choice from some fixed set of possibilities and are meaningless on their own. The only thing that’s unrepresentable is a choice from infinitely many possibilities, for obvious reasons, though of course the bounds of the physical universe will get you much sooner.
You might be interested in this paper [1] which builds on top of this approach to simulate arbitrarily precise samples from the continuous normal distribution.
Infinities defy simple assumptions about maths, while Maxwell's Demon only needs to ignore the Laws of Thermodynamics.
I'm being serious, not glib, here. "And then do it infinitely many times" doesn't automatically enable any possible outcome, any more than the "multiverse of all possible outcomes" enables hot dog fingers on Jamie Curtis.
When you apply the same test to the output of Math.PI, does it pass?
https://en.wikipedia.org/wiki/Integer: “An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...)”
According to that definition, -0 isn’t an integer.
Combining that with https://en.wikipedia.org/wiki/Rational_number: “a rational number is a number that can be expressed as the quotient or fraction p/q of two integers, a numerator p and a non-zero denominator q”
means there’s no way to write -0 as the quotient or fraction p/q of two integers, a numerator p and a non-zero denominator q.
Of course, we can only measure any quantity up to a finite precision. But the fact that we chose to express the measurement outcome as 3.14159 +- 0.00001 instead of expressing it as Pi +- 0.00001 is an arbitrary choice. If the theory predicts that some path has length equal exactly to 2.54, we are in the same situation - we can't confirm with infinite precision that the measurement is exactly 2.54, we'll still get something like 2.54 +- 0.00001, so it could very well be some irrational number in actual reality.
This is how old temperature-noise based TRNGs can be attacked (modern ones use a different technique, usually a ring-oscillater with whitening... although i have heard noise-based is coming back but i've been out of the loop for a while)
https://en.wikipedia.org/wiki/Hardware_random_number_generat...
https://github.com/usnistgov/SP800-90B_EntropyAssessment
(^^^ this is a fun tool, I recommend playing with it to learn how challenging it is to generate "true" random numbers.)
An infinite precision ADC couldn't be subject to thermal attack because you could just sample more bits of precision. (Of course, then we'd be down to Planck level precision so obviously there are limits, but my point still stands, at least _I_ think it does. :))