Skip to content
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

0x10000000000000000.pow(3) is computed incorrectly #30

Closed
huonw opened this issue Oct 22, 2015 · 0 comments
Closed

0x10000000000000000.pow(3) is computed incorrectly #30

huonw opened this issue Oct 22, 2015 · 0 comments

Comments

@huonw
Copy link
Contributor

huonw commented Oct 22, 2015

extern crate ramp;
extern crate gmp;
use ramp::Int;
use gmp::mpz::Mpz;

macro_rules! eq {
    ($r: expr, $g: expr) => {
        assert_eq!($r.to_str_radix(16, false), $g.to_str_radix(16))
    }
}

fn parse(s: &str) -> (Int, Mpz) {
    (Int::from_str_radix(s, 16).unwrap(),
     Mpz::from_str_radix(s, 16).unwrap())
}
fn main() {
    let (ar, ag) = parse("10000000000000000");

    eq!(ar.pow(3),
        ag.pow(3));
}
thread '<main>' panicked at 'assertion failed: `(left == right)` (left: `"10000000000000000"`, right: `"1000000000000000000000000000000000000000000000000"`)', examples/isolated.rs:19

There has to be at least that many trailing zeros, presumably so that the lowest word is empty. And .pow(2) is computed correctly.

huonw added a commit to huonw/ramp that referenced this issue Oct 22, 2015
This compares pretty much every operation Ramp exposes against the
result of the same computation performed with GMP.

Several bugs/issues were found, and the corresponding tests are
currently commented out: Aatch#24, Aatch#25, Aatch#26, Aatch#27, Aatch#30.
huonw added a commit to huonw/ramp that referenced this issue Oct 23, 2015
Something like `(odd * 2**64)**3` should be computed as `odd**3 * 2**(64
* 3)`, but it was being computed as just `odd**exp * 2**64`.

Fixes Aatch#30.
huonw added a commit to huonw/ramp that referenced this issue Oct 23, 2015
Something like `(odd * 2**64)**3` should be computed as `odd**3 * 2**(64
* 3)`, but it was being computed as just `odd**3 * 2**64`.

Fixes Aatch#30.
@Aatch Aatch closed this as completed in #35 Oct 23, 2015
huonw added a commit to huonw/ramp that referenced this issue Oct 23, 2015
Bias toward long sequences of just 0's or just 1's. GMP's mpz_rrandomb's
docs say that these seem to be more likely to pick up edge cases. This
assertion make sense: for most algorithms, only zero or all-bits-set (or
1) have useful special cases. Also, this seems to be bourne out in
practice with Ramp e.g. Aatch#30 was only picked up by a earlier version of
biasing like this, with uniform bits, the chance of getting a trailing
zero word to trigger that is 2**-64.

Examples of numbers generated by this distribution (in hex):

    bdfffffffffffffffffffffffffffffffffffffffffffffffffae00000000000000000000000000000000000000000a3a188
    bfffffffffffffc2222000000000000000000000000000000000000000000000000000000000000f9a00000000bd4f845457
    b9fffffffffff25000097e8126ffffffffffefffffffffffffffffffffffffffffffffffffffffd5c7aeffffffffffffffff
    f00000000000003ffffffffff1f14fffffffffffff3fffffff76dd6fffffffffffffffffffffffffff1288b9000000000000
    c6cff00000000007ff8ffffffffffffff63ad6dce80000000000000000000000000000020000000000000000000000f3ea39
    4fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcd996c00000000000000000000000000
    c00000000000000000003fffffff100000000000000000000000000000000020000000000000000000000000033ec4958000
    bae4a67fe0cffffffffff70bcd7c80220000000000000000000000000000000000000000840008d9a9aa009f400000000000
    beacc705c1fffffff3a8c2d9788d3ca516322fffffffffffffffffffffffe0805c5da9b071fffffffffffffddfffffffffff
    ef23600000000000000000b54d000000000000000000000000000000000000a5fffffffffd83200000000000000000000000
    7ffffffffffffffffffffffffffffffffffffffffffffffffffffffff7cffffffffffcfffffffffffff9aefffffffffffe7f
huonw added a commit to huonw/ramp that referenced this issue Oct 24, 2015
Bias toward long sequences of just 0's or just 1's. GMP's mpz_rrandomb's
docs say that these seem to be more likely to pick up edge cases. This
assertion make sense: for most algorithms, only zero or all-bits-set (or
1) have useful special cases. Also, this seems to be bourne out in
practice with Ramp e.g. Aatch#30 was only picked up by a earlier version of
biasing like this, with uniform bits, the chance of getting a trailing
zero word to trigger that is 2**-64.

Examples of numbers generated by this distribution (in hex):

bdfffffffffffffffffffffffffffffffffffffffffffffffffae00000000000000000000000000000000000000000a3a188
bfffffffffffffc2222000000000000000000000000000000000000000000000000000000000000f9a00000000bd4f845457
b9fffffffffff25000097e8126ffffffffffefffffffffffffffffffffffffffffffffffffffffd5c7aeffffffffffffffff
f00000000000003ffffffffff1f14fffffffffffff3fffffff76dd6fffffffffffffffffffffffffff1288b9000000000000
c6cff00000000007ff8ffffffffffffff63ad6dce80000000000000000000000000000020000000000000000000000f3ea39
4fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcd996c00000000000000000000000000
c00000000000000000003fffffff100000000000000000000000000000000020000000000000000000000000033ec4958000
bae4a67fe0cffffffffff70bcd7c80220000000000000000000000000000000000000000840008d9a9aa009f400000000000
beacc705c1fffffff3a8c2d9788d3ca516322fffffffffffffffffffffffe0805c5da9b071fffffffffffffddfffffffffff
ef23600000000000000000b54d000000000000000000000000000000000000a5fffffffffd83200000000000000000000000
7ffffffffffffffffffffffffffffffffffffffffffffffffffffffff7cffffffffffcfffffffffffff9aefffffffffffe7f
huonw added a commit to huonw/ramp that referenced this issue Oct 26, 2015
Bias toward long sequences of just 0's or just 1's. GMP's mpz_rrandomb's
docs say that these seem to be more likely to pick up edge cases. This
assertion make sense: for most algorithms, only zero or all-bits-set (or
1) have useful special cases. Also, this seems to be bourne out in
practice with Ramp e.g. Aatch#30 was only picked up by a earlier version of
biasing like this, with uniform bits, the chance of getting a trailing
zero word to trigger that is 2**-64.

Examples of numbers generated by this distribution (in hex):

    bdfffffffffffffffffffffffffffffffffffffffffffffffffae00000000000000000000000000000000000000000a3a188
    bfffffffffffffc2222000000000000000000000000000000000000000000000000000000000000f9a00000000bd4f845457
    b9fffffffffff25000097e8126ffffffffffefffffffffffffffffffffffffffffffffffffffffd5c7aeffffffffffffffff
    f00000000000003ffffffffff1f14fffffffffffff3fffffff76dd6fffffffffffffffffffffffffff1288b9000000000000
    c6cff00000000007ff8ffffffffffffff63ad6dce80000000000000000000000000000020000000000000000000000f3ea39
    4fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcd996c00000000000000000000000000
    c00000000000000000003fffffff100000000000000000000000000000000020000000000000000000000000033ec4958000
    bae4a67fe0cffffffffff70bcd7c80220000000000000000000000000000000000000000840008d9a9aa009f400000000000
    beacc705c1fffffff3a8c2d9788d3ca516322fffffffffffffffffffffffe0805c5da9b071fffffffffffffddfffffffffff
    ef23600000000000000000b54d000000000000000000000000000000000000a5fffffffffd83200000000000000000000000
    7ffffffffffffffffffffffffffffffffffffffffffffffffffffffff7cffffffffffcfffffffffffff9aefffffffffffe7f
huonw added a commit to huonw/ramp that referenced this issue Oct 27, 2015
Bias toward long sequences of just 0's or just 1's. GMP's mpz_rrandomb's
docs say that these seem to be more likely to pick up edge cases. This
assertion make sense: for most algorithms, only zero or all-bits-set (or
1) have useful special cases. Also, this seems to be bourne out in
practice with Ramp e.g. Aatch#30 was only picked up by a earlier version of
biasing like this, with uniform bits, the chance of getting a trailing
zero word to trigger that is 2**-64.

Examples of numbers generated by this distribution (in hex):

    bdfffffffffffffffffffffffffffffffffffffffffffffffffae00000000000000000000000000000000000000000a3a188
    bfffffffffffffc2222000000000000000000000000000000000000000000000000000000000000f9a00000000bd4f845457
    b9fffffffffff25000097e8126ffffffffffefffffffffffffffffffffffffffffffffffffffffd5c7aeffffffffffffffff
    f00000000000003ffffffffff1f14fffffffffffff3fffffff76dd6fffffffffffffffffffffffffff1288b9000000000000
    c6cff00000000007ff8ffffffffffffff63ad6dce80000000000000000000000000000020000000000000000000000f3ea39
    4fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcd996c00000000000000000000000000
    c00000000000000000003fffffff100000000000000000000000000000000020000000000000000000000000033ec4958000
    bae4a67fe0cffffffffff70bcd7c80220000000000000000000000000000000000000000840008d9a9aa009f400000000000
    beacc705c1fffffff3a8c2d9788d3ca516322fffffffffffffffffffffffe0805c5da9b071fffffffffffffddfffffffffff
    ef23600000000000000000b54d000000000000000000000000000000000000a5fffffffffd83200000000000000000000000
    7ffffffffffffffffffffffffffffffffffffffffffffffffffffffff7cffffffffffcfffffffffffff9aefffffffffffe7f
huonw added a commit to huonw/ramp that referenced this issue Oct 27, 2015
Bias toward long sequences of just 0's or just 1's. GMP's mpz_rrandomb's
docs say that these seem to be more likely to pick up edge cases. This
assertion make sense: for most algorithms, only zero or all-bits-set (or
1) have useful special cases. Also, this seems to be bourne out in
practice with Ramp e.g. Aatch#30 was only picked up by a earlier version of
biasing like this, with uniform bits, the chance of getting a trailing
zero word to trigger that is 2**-64.

Examples of numbers generated by this distribution (in hex):

    bdfffffffffffffffffffffffffffffffffffffffffffffffffae00000000000000000000000000000000000000000a3a188
    bfffffffffffffc2222000000000000000000000000000000000000000000000000000000000000f9a00000000bd4f845457
    b9fffffffffff25000097e8126ffffffffffefffffffffffffffffffffffffffffffffffffffffd5c7aeffffffffffffffff
    f00000000000003ffffffffff1f14fffffffffffff3fffffff76dd6fffffffffffffffffffffffffff1288b9000000000000
    c6cff00000000007ff8ffffffffffffff63ad6dce80000000000000000000000000000020000000000000000000000f3ea39
    4fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcd996c00000000000000000000000000
    c00000000000000000003fffffff100000000000000000000000000000000020000000000000000000000000033ec4958000
    bae4a67fe0cffffffffff70bcd7c80220000000000000000000000000000000000000000840008d9a9aa009f400000000000
    beacc705c1fffffff3a8c2d9788d3ca516322fffffffffffffffffffffffe0805c5da9b071fffffffffffffddfffffffffff
    ef23600000000000000000b54d000000000000000000000000000000000000a5fffffffffd83200000000000000000000000
    7ffffffffffffffffffffffffffffffffffffffffffffffffffffffff7cffffffffffcfffffffffffff9aefffffffffffe7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant