From:

Date:

March 5, 2001 11:33Subject:

Re: [ID 20010305.005] "use integer" doesn't make rand() return integersMessage ID:

15011.59838.290107.292862@rls.cxf> ----------------------------------------------------------------- f> The following program doesn't print a sequence of integers as one f> would expect. f> use integer; for(;;) { print rand 10; } f> ----------------------------------------------------------------- I don't think this is a bug. perldoc -f rand says: Returns a random fractional number greater than or equal t.... perldoc integer says: integer - Perl pragma to compute arithmetic in integer instead of double As "rand" isn't really a perl-level integer computation, (it can almost be thought of as a black box that spits out "random fractional numbers"), I think the proper thing is to just convert it by hand if that's what you want: print int(rand 10); (The patch to make rand return an integer under use integers is somewhat trivial.. if (PL_hints & HINT_INTEGER) value = floor(value); before the push.. I think.) -RThread Previous | Thread Next

- [ID 20010305.005] "use integer" doesn't make rand() return integers by fanf
**Re: [ID 20010305.005] "use integer" doesn't make rand() return integers**by rspier- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John L. Allen
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by rspier
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by rspier
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Walt Mankowski
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John L. Allen
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Philip Newton
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Tony Finch
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Philip Newton
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by rspier
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Philip Newton
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Ronald J Kimball
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Nicholas Clark
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About