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

Incorrect computations with Big_int #3586

Closed
vicuna opened this issue Apr 8, 2005 · 1 comment
Closed

Incorrect computations with Big_int #3586

vicuna opened this issue Apr 8, 2005 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 8, 2005

Original bug ID: 3586
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

I've run across some odd problems with the Big_int module where some
expressions seem to evaluate to odd values. Here is some code that
demonstrates this problem:

(***********************************)

#load "nums.cma";;
open Big_int;;

let pow_of_two = power_int_positive_int 2;;
let pow13 bi = power_big_int_positive_int bi 13;;

(* This works fine )
string_of_big_int (pow13 (pow_of_two 51));;
(

- : string =

"38272525864510487788655081260950309410329935801733327822136058989190002
861848048793862592256319392263154317107227530633921701753935367770195646
260767912323717284188541295913442384799112073398408183808"
*)

(* This fails )
string_of_big_int (pow13 (pow_of_two 52));;
(

- : string = "0"

*)

(* This equivalent computation works )
string_of_big_int (pow_of_two (52 * 13));;
(

- : string =

"31352853188206991596466242568970493468942283408779942151893859523944450
344425921571932235576376846141976016574240793095308658076823853277344273
4168210737755891992072530296122920016274326105279759841755136"
*)

(* However, while it is converting to "0", it is not equal to 0 )
eq_big_int (pow13 (pow_of_two 52)) zero_big_int;;
(

- : bool = false

*)

(* But it's not 2^676 either... *)
eq_big_int (pow13 (pow_of_two 52)) (pow_of_two (52 * 13));;

(*

- : bool = false

*)

(* And just a bit more information )
lt_big_int (pow13 (pow_of_two 52)) unit_big_int;;
gt_big_int (pow13 (pow_of_two 52)) zero_big_int;;
(

  • : bool = true
  • : bool = true
    *)

(***********************************)

A quick check reveals that (pow13 (pow_of_two x)) shows this problem
for x = 37, 42, 47, and 52-63 (0 <= x <= 100).

This problem occurs on both 3.08.0 under Mac OS X on a G4, and 3.08.1
under Linux on a P4. Let me know if you need any more information.

William D. Neumann

"You've got Rita Marlowe in the palm of your hand."
"Palm of my hand? You haven't seen Rita Marlowe..."

	-- Will Success Spoil Rock Hunter?
@vicuna
Copy link
Author

vicuna commented Jul 29, 2005

Comment author: administrator

Same bug as #3718. Fixed in 3.08.4 by XL, 2005-07-19

@vicuna vicuna closed this as completed Jul 29, 2005
@vicuna vicuna added the bug label Mar 19, 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