-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:check for float types never produces subnormal numbers #1052
Comments
The random generator for floats is here: cryptol/src/Cryptol/Testing/Random.hs Line 257 in 9b9f452
I think it's technically possible to produce subnormal numbers, just quite unlikely, even for small float types. |
I can get |
Agreed. I've been using a more sophosticated generator for some What4 testing I'll probably port here. It switches, with fixed probabilities, between selecting special numbers (NaN, Inf, zeros), selecting numbers "mathematically" (but better than here, I think), and selecting numbers based on their bitwise representation. The bitwise form can be tweaked to produce subnormals quite easily. |
If I understand the code correctly, it looks like floats are generated as rational numbers, where the numerator and denominator are chosen from uniform distributions of the same magnitude. This means that this distribution will be biased rather heavily towards numbers near 1. So not only will subnormals be rare, but also very large numbers will be quite rare as well. |
I believe that's correct, yes. |
Indeed, you have to do a lot of searching to find a
(Doing a million tests was enough to find one, though.) |
Fixed via #1069 |
Even with a very large number of tests (like a million) we never come across any examples where the exponent is all 0 bits, except for 0.0.
Note that this can't be tested with
:exhaust
, due to #1051.The text was updated successfully, but these errors were encountered: