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

Random.int 0 ==> Exception: Invalid_argument "Random.int". #4192

Closed
vicuna opened this issue Jan 4, 2007 · 3 comments
Closed

Random.int 0 ==> Exception: Invalid_argument "Random.int". #4192

vicuna opened this issue Jan 4, 2007 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 4, 2007

Original bug ID: 4192
Reporter: johnm
Status: closed (set by @damiendoligez on 2007-01-10T22:12:57Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 3.09.3
Category: ~DO NOT USE (was: OCaml general)

Bug description

Random.int should complain if the argument is negative but if the argument is exactly 0 it seems to me the function ought to return 0.

:; ocaml
Objective Caml version 3.09.3

Random.int 0;;

Exception: Invalid_argument "Random.int".

@vicuna
Copy link
Author

vicuna commented Jan 7, 2007

Comment author: @mmottl

I don't think so. The function behaves exactly as specified in the documentation. "Random.int n" will chose one of n numbers, namely the numbers ranging from 0 to n-1. One cannot chose a number out of zero numbers.

@vicuna
Copy link
Author

vicuna commented Jan 10, 2007

Comment author: johnm

True enough. I guess I had an off by 1 error.

Random.int 1;;

  • : int = 0

I'm not sure how to withdraw this report but that's what I want to do.

@vicuna
Copy link
Author

vicuna commented Jan 10, 2007

Comment author: @damiendoligez

made a slight change to the docs

@vicuna vicuna closed this as completed Jan 10, 2007
@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