From:

Date:

March 6, 2001 14:13Subject:

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

20010306221043.17830.qmail@foad.orgOn Tue, Mar 06, 2001 at 02:08:02PM -0500, John Peacock wrote: > Tony Finch wrote: > > > > >I agree that it does fit DWIM, but since rand() returns a float between > > >0 and 0.999999999, what would the corresponding integer range be: > > >0-10, 0-100, 0-1000??? I think this is one of those cases where the > > >user has to make that determination for themselves. > > > > I suggest 0..1. > > For use integer; print rand; I would expect the range to be 0 .. 0. But for use integer; print rand (10); I would expect the range to be 0 .. 9 inclusive. > I can see some utility for (the original code) > > use integer; > for(;;) { > print rand 10; > } > > to return integers from 0..9, and it is even easy to create a patch > to do that. The problem comes when someone codes this: > > use integer; > for(;;) { > print rand; > } > > because this has no meaning. The range of integers 0..1 is not > as easily derivable from rand()'s 0..0.999999999 (you'd have to use > round). > > Since 'use integer' strictly affects mathematic operations, not > mathematic functions, I think this is not a good enhancement. Could you please, from a mathematical viewpoint, tell me what the difference is between an operator and a function? Even from a CS standpoint, the only differences are syntactical details, only relevant to parsing tables, and largely artificial. AbigailThread 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