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

Big_int.shift_right* methods never yield zero_big_int #5123

Closed
vicuna opened this issue Aug 9, 2010 · 2 comments
Closed

Big_int.shift_right* methods never yield zero_big_int #5123

vicuna opened this issue Aug 9, 2010 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 9, 2010

Original bug ID: 5123
Reporter: profjim
Status: closed (set by @damiendoligez on 2010-08-18T13:22:56Z)
Resolution: fixed
Priority: normal
Severity: tweak
Version: 3.12.0
Fixed in version: 3.12.1+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

compare Big_int.(shift_right_big_int (big_int_of_int 1) 1) (Big_int.zero_big_int);;

  • : int = 1

This is because the shift_right methods just copy over the sign of the first argument, without checking whether the value has gone to zero. However:

compare Big_int.(add_big_int (shift_right_big_int (big_int_of_int 1) 1) zero_big_int) (Big_int.zero_big_int);;

  • : int = 0
@vicuna
Copy link
Author

vicuna commented Aug 9, 2010

Comment author: profjim

Using Big_int.compare_big_int instead of Pervasives.compare also fails:

Big_int.compare_big_int (Big_int.shift_right_big_int (Big_int.big_int_of_int 1) 1) (Big_int.zero_big_int);;

  • : int = 1

@vicuna
Copy link
Author

vicuna commented Aug 18, 2010

Comment author: @damiendoligez

Thanks for the report. This will be fixed in 3.12.1.

@vicuna vicuna closed this as completed Aug 18, 2010
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant