From:

Date:

March 7, 2001 12:23Subject:

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

20010307202031.19842.qmail@foad.orgOn Wed, Mar 07, 2001 at 10:22:31AM -0500, John Peacock wrote: > abigail@foad.org wrote: > > > > On Tue, Mar 06, 2001 at 02:08:02PM -0500, John Peacock wrote: > > > 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. > > > > Abigail > > It is not a matter of mathematics, it is a matter of which underlying > math library Perl is going to apply. I'm not sure that's something you should strive for. The underlying libraries, if any, should not matter for the programmer. We already have enough of that in Perl. > use integer; > my $float=1.434; > my $int = 12; > > $int += 4.5; # $int is now 16, not 16.5 > $int += $float; # $int is now 17 > $float += 1; # $float is now 2 (an integer) > > $float = sin(30);# $float is now -0.988031624092862 (not an integer) > print $int, "\t", $float, "\n"; > > sin, tan, rand, etc are mathematic functions contained within the > underlying floating point math library. "use integer" has no impact > on them, nor IMHO should it. The math operations +, -, *, / are > affected by "use integer" because the value is cast to an integer > and the integer math functions are used. That is the point of > "use integer" after all. There is really no point in extending it > to rand (and certainly no point in applying it to sin, tan, etc). If there was no point, why was it requested? "No point" is merely your opinion, nothing more or less. I find rand() returning integers nothing stranger than 3.7 + 1.6 equalling 4. Why would you *want* rand() to return non-integers if you are doing integer arithmetic anyway? 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