integer generator can't generate very large integers #82

Closed
puzza007 opened this Issue Feb 11, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@puzza007
Contributor

puzza007 commented Feb 11, 2014

Because it uses floats, it seems.

1> proper_gen:integer_gen(1, -(1 bsl 2000), 1 bsl 2000).
** exception error: an error occurred when evaluating an arithmetic expression
     in function  random:uniform/1 (random.erl, line 112)
     in call from proper_arith:rand_int/2 (src/proper_arith.erl, line 242)

where:

-spec rand_int(integer(), integer()) -> integer().
rand_int(Low, High) when is_integer(Low), is_integer(High), Low =< High ->
    Low + random:uniform(High - Low + 1) - 1.
@kostis

This comment has been minimized.

Show comment
Hide comment
@kostis

kostis Feb 11, 2014

Collaborator

I consider this to be actually a bug in random:uniform/1 instead of PropEr.

Let's see what the people at the erlang-bugs mailing list have to say about it...

Collaborator

kostis commented Feb 11, 2014

I consider this to be actually a bug in random:uniform/1 instead of PropEr.

Let's see what the people at the erlang-bugs mailing list have to say about it...

@kostis

This comment has been minimized.

Show comment
Hide comment
@kostis

kostis Jun 21, 2016

Collaborator

This seems to be fixed in recent Erlang/OTP releases. I will now close the issue.

Collaborator

kostis commented Jun 21, 2016

This seems to be fixed in recent Erlang/OTP releases. I will now close the issue.

@kostis kostis closed this Jun 21, 2016

@puzza007

This comment has been minimized.

Show comment
Hide comment
@puzza007

puzza007 Jun 21, 2016

Contributor

Looks good. Thanks.

2> proper_gen:integer_gen(1 bsl 1022, -(1 bsl 2000), 1 bsl 2000).
18288345913831963564278180683792828110236640566260821542579560513502807169509771318586802441064411946401904626481038694124199422264544457563491868951012494962749198245589973846361032662968092252252292522565388594977571085674973926253044432936634097506242596138189991108509211457391643942777868411342250049536
229> proper_gen:integer_gen(1 bsl 1022, -(1 bsl 2000), 1 bsl 2000).
-32313629287232179924323887839921189227647438813802353462032885409443868869043412909963196531742573526117821573766187467634846735389628124164956055313366610193463142390396535772546428902823033771831507878124324515752039352354896768832469955762810864941456639847289161087285705472986594810842642038185195995136
3>
Contributor

puzza007 commented Jun 21, 2016

Looks good. Thanks.

2> proper_gen:integer_gen(1 bsl 1022, -(1 bsl 2000), 1 bsl 2000).
18288345913831963564278180683792828110236640566260821542579560513502807169509771318586802441064411946401904626481038694124199422264544457563491868951012494962749198245589973846361032662968092252252292522565388594977571085674973926253044432936634097506242596138189991108509211457391643942777868411342250049536
229> proper_gen:integer_gen(1 bsl 1022, -(1 bsl 2000), 1 bsl 2000).
-32313629287232179924323887839921189227647438813802353462032885409443868869043412909963196531742573526117821573766187467634846735389628124164956055313366610193463142390396535772546428902823033771831507878124324515752039352354896768832469955762810864941456639847289161087285705472986594810842642038185195995136
3>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment