Re: Please help me! Thanks.

2003-12-17 Thread drieux
On Dec 17, 2003, at 9:36 AM, Randal L. Schwartz wrote: "Drieux" == Drieux <[EMAIL PROTECTED]> writes: Drieux> neat solution, minor problem is that Math::Fraction Drieux> is not a 'default' module yet. And if that's a problem for you, you aren't using Perl properly yet. could well be. help clarify

Re: Please help me! Thanks.

2003-12-17 Thread Randal L. Schwartz
> "Drieux" == Drieux <[EMAIL PROTECTED]> writes: Drieux> neat solution, minor problem is that Math::Fraction Drieux> is not a 'default' module yet. And if that's a problem for you, you aren't using Perl properly yet. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777

Re: Please help me! Thanks.

2003-12-16 Thread Rob Dixon
R. Joseph Newton wrote: > > Rob Dixon wrote: > > > > It's also worth pointing out here that rational values are almost always what is > > wanted in this sort of situation. > > > > The (very nice indeed) Math::Fraction module lets you do just this. The only > > changes to the code are to initialise

Re: Please help me! Thanks.

2003-12-16 Thread R. Joseph Newton
Rob Dixon wrote: > Hacksaw wrote: > > > > > now, a stupid solution is: > > > > > > for (my $value = -1000; $value <= 1000; $value += 100) { > > > print $value/1000, "\n"; > > > } > > > > > > hehe, > > > > > > > Sadly, it's not as stupid as you think. Unless I misunderstand things, what > >

Re: Please help me! Thanks.

2003-12-16 Thread drieux
On Dec 16, 2003, at 7:16 AM, Rob Dixon wrote: [..] Rob use strict; use warnings; use Math::Fraction; for (my $value = frac -1; $value <= 1; $value += 0.1) { print $value->decimal, "\n"; } [..] neat solution, minor problem is that Math::Fraction is not a 'default' module yet.

Re: Please help me! Thanks.

2003-12-16 Thread Rob Dixon
Hacksaw wrote: > > > now, a stupid solution is: > > > > for (my $value = -1000; $value <= 1000; $value += 100) { > > print $value/1000, "\n"; > > } > > > > hehe, > > > > Sadly, it's not as stupid as you think. Unless I misunderstand things, what > you are seeing here is a problem called IEE

Re: Please help me! Thanks.

2003-12-16 Thread R. Joseph Newton
Paul Johnson wrote: > On Tue, Dec 16, 2003 at 02:25:42PM +0800, pagoda wrote: > > > now, a stupid solution is: > > > > for (my $value = -1000; $value <= 1000; $value += 100) { > > print $value/1000, "\n"; > > } > > > > hehe, > > Not so stupid, really. If you can keep most of your maths co

Re: Please help me! Thanks.

2003-12-16 Thread Mr M senthil kumar
On Tue, 16 Dec 2003, pagoda wrote: > > for (my $value = -1; $value <= 1; $value += 0.1) { > print "$value\n"; > } Hi, I don't know if it might be helpful, but the following code works better: for ($value = -1; $value <= 1; $value += 0.1) { printf ("%.1f\n",$value); } This p

RE: Please help me! Thanks.

2003-12-15 Thread Charles K. Clarkson
pagoda <[EMAIL PROTECTED]> wrote: : Take a look at the first question in perlfaq4: Why am I getting long decimals (eg, 19.94999) instead of the numbers I should be getting (eg, 19.95)? HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists

Re: Please help me! Thanks.

2003-12-15 Thread Paul Johnson
On Tue, Dec 16, 2003 at 02:25:42PM +0800, pagoda wrote: > now, a stupid solution is: > > for (my $value = -1000; $value <= 1000; $value += 100) { > print $value/1000, "\n"; > } > > hehe, Not so stupid, really. If you can keep most of your maths confined to integers you will have fewer

Re: Please help me! Thanks.

2003-12-15 Thread Hacksaw
> now, a stupid solution is: > > for (my $value = -1000; $value <= 1000; $value += 100) { > print $value/1000, "\n"; > } > > hehe, > Sadly, it's not as stupid as you think. Unless I misunderstand things, what you are seeing here is a problem called IEEE 754 floating point. I'm sure th

Re: Please help me! Thanks.

2003-12-15 Thread pagoda
now, a stupid solution is: for (my $value = -1000; $value <= 1000; $value += 100) { print $value/1000, "\n"; } hehe, - Original Message - From: "pagoda" <[EMAIL PROTECTED]> To: "begin begin" <[EMAIL PROTECTED]> Sent: Tuesday, December 16, 2003 1:54 PM Subject: Please help me!