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
RNG-81: NumberFactory to sample all rationals between 0 and 1. #29
Conversation
a094e93
to
72aa242
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall seems reasonable to me
Assert.assertEquals(0, (noBits >>> 9) * 0x1.0p-23f, 0); | ||
Assert.assertEquals(0, (noBits >>> 8) * 0x1.0p-24f, 0); | ||
Assert.assertEquals(0, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) - 1.0f, 0); | ||
Assert.assertEquals(0f, (noBits >>> 9) * 0x1.0p-23f, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: if you're changing the first argument anyways use the canonical form
Assert.assertEquals(0f, (noBits >>> 9) * 0x1.0p-23f, 0); | |
Assert.assertEquals(0.0f, (noBits >>> 9) * 0x1.0p-23f, 0); |
Assert.assertEquals(0, (noBits >>> 8) * 0x1.0p-24f, 0); | ||
Assert.assertEquals(0, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) - 1.0f, 0); | ||
Assert.assertEquals(0f, (noBits >>> 9) * 0x1.0p-23f, 0); | ||
Assert.assertEquals(0f, (noBits >>> 8) * 0x1.0p-24f, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert.assertEquals(0f, (noBits >>> 8) * 0x1.0p-24f, 0); | |
Assert.assertEquals(0.0f, (noBits >>> 8) * 0x1.0p-24f, 0); |
Assert.assertEquals(0, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) - 1.0f, 0); | ||
Assert.assertEquals(0f, (noBits >>> 9) * 0x1.0p-23f, 0); | ||
Assert.assertEquals(0f, (noBits >>> 8) * 0x1.0p-24f, 0); | ||
Assert.assertEquals(0f, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) - 1.0f, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert.assertEquals(0f, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) - 1.0f, 0); | |
Assert.assertEquals(0.0f, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) - 1.0f, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed all 0f
with 0.0f
. Thanks.
This changes the nextFloat/nextDouble methods to use an extra bit of state from the underlying int or long primitive.
72aa242
to
647326a
Compare
This changes the nextFloat/nextDouble methods to use an extra bit of
state from the underlying int or long primitive.