Re: misunderstanding (was: Re: bug in perl?)

2009-07-18 Thread Chas. Owens
2009/7/18 Octavian Râşniţă : > From: "Dr.Ruud" > Octavian Rasnita wrote: >> >>> print 0.79 - 0.798; >>> >>> -0.00801 >>> >>> which is obviously wrong. >> >> And it is obvious to me that you are wrong. Funny hey? >> >> -- >> Ruud > > Sorry but the calculation is obviously wrong. It is n

Re: misunderstanding (was: Re: bug in perl?)

2009-07-18 Thread Octavian Râşniţă
From: "Dr.Ruud" Octavian Rasnita wrote: print 0.79 - 0.798; -0.00801 which is obviously wrong. And it is obvious to me that you are wrong. Funny hey? -- Ruud Sorry but the calculation is obviously wrong. It is not my fault that the computers can't make a perfect float calcu

misunderstanding (was: Re: bug in perl?)

2009-07-18 Thread Dr.Ruud
Octavian Rasnita wrote: print 0.79 - 0.798; -0.00801 which is obviously wrong. And it is obvious to me that you are wrong. Funny hey? -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org

Re: bug in perl

2009-07-18 Thread Octavian Râsnita
From: "Telemachus" On Fri Jul 17 2009 @ 3:18, Octavian Rasnita wrote: From: "Shawn H. Corey" Octavian Rasnita wrote: Well, in PHP that calculation is made well, so I think there is a bug in perl. No, it's not. PHP rounds off the number before printing. In Perl

Re: bug in perl

2009-07-17 Thread Telemachus
On Fri Jul 17 2009 @ 3:18, Octavian Rasnita wrote: > From: "Shawn H. Corey" >> Octavian Rasnita wrote: >>> Well, in PHP that calculation is made well, so I think there is a bug >>> in perl. >>> >> >> No, it's not. PHP rounds of

Re: bug in perl?

2009-07-17 Thread Octavian Rasnita
From: "Shawn H. Corey" Octavian Rasnita wrote: Well, in PHP that calculation is made well, so I think there is a bug in perl. No, it's not. PHP rounds off the number before printing. In Perl: printf "%.2f", $x; or $x = sprintf "%.2f", $x; Ok, tha

Re: bug in perl?

2009-07-17 Thread Shawn H. Corey
Octavian Rasnita wrote: Well, in PHP that calculation is made well, so I think there is a bug in perl. No, it's not. PHP rounds off the number before printing. In Perl: printf "%.2f", $x; or $x = sprintf "%.2f", $x; -- Just my 0.0002 million dollars worth

Re: bug in perl?

2009-07-17 Thread Bob goolsby
The basic issue is one of representation -- your represent numbers in base 10 (decimal); the Machine represents numbers in base 2 (binary). When you (or the Machine) translates between bases, there may be some loss in precision -- a number that is finite, terminating fraction in base19 (0.78, for

Re: bug in perl?

2009-07-17 Thread Octavian Rasnita
wonderful world of machine numbers. Well, in PHP that calculation is made well, so I think there is a bug in perl. Anyway, I knew about this issues in languages like perl and python, but I hoped there should be a solution for it and I found that I can use Math::BigFloat: use strict; use Math

AW: bug in perl?

2009-07-17 Thread Thomas Bätzler
Paul Johnson wrote: > On Fri, Jul 17, 2009 at 12:26:58PM +0200, Thomas Bätzler wrote: > > Octavian Rasnita asked: > > > I have tried the following calculation with ActivePerl 5.10.0 build > > > 1004 under Windows XP Pro: > > > > > > print 0.79 - 0.798; > > > > > > And it gave the following result

Re: bug in perl?

2009-07-17 Thread Shawn H. Corey
Paul Johnson wrote: On Fri, Jul 17, 2009 at 12:26:58PM +0200, Thomas Bätzler wrote: Octavian Rasnita asked: I have tried the following calculation with ActivePerl 5.10.0 build 1004 under Windows XP Pro: print 0.79 - 0.798; And it gave the following result: -0.00801 which

Re: bug in perl?

2009-07-17 Thread Paul Johnson
On Fri, Jul 17, 2009 at 12:26:58PM +0200, Thomas Bätzler wrote: > Octavian Rasnita asked: > > I have tried the following calculation with ActivePerl 5.10.0 build 1004 > > under Windows XP Pro: > > > > print 0.79 - 0.798; > > > > And it gave the following result: > > -0.00801 > > > >

AW: bug in perl?

2009-07-17 Thread Thomas Bätzler
Octavian Rasnita asked: > I have tried the following calculation with ActivePerl 5.10.0 build 1004 > under Windows XP Pro: > > print 0.79 - 0.798; > > And it gave the following result: > -0.00801 > > which is obviously wrong. No, it isn't. Welcome to the wonderful world of machine

bug in perl?

2009-07-17 Thread Octavian Rasnita
Hi, I have tried the following calculation with ActivePerl 5.10.0 build 1004 under Windows XP Pro: print 0.79 - 0.798; And it gave the following result: -0.00801 which is obviously wrong. It doesn't matter too much the reasons, but is there a better way for doing such math calc

Re: Bug in Perl [OT]

2008-10-10 Thread Mr. Shawn H. Corey
On Fri, 2008-10-10 at 14:36 +0100, Dermot wrote: > 2008/10/10 Jeff Pang <[EMAIL PROTECTED]>: > >> Message du 10/10/08 13:57 > >> De : "Mr. Shawn H. Corey" > >> -- > >> Just my 0.0002 million dollars worth, > >> Shawn > >> > >> Linux is obsolete. > >> -- Andrew Tanenbaum > >> > > > > > > Shawn

Re: Bug in Perl [OT]

2008-10-10 Thread Dermot
2008/10/10 Jeff Pang <[EMAIL PROTECTED]>: >> Message du 10/10/08 13:57 >> De : "Mr. Shawn H. Corey" >> -- >> Just my 0.0002 million dollars worth, >> Shawn >> >> Linux is obsolete. >> -- Andrew Tanenbaum >> > > > Shawn, I just ask out of curiosity, your signature said: > > "Linux is obsolete.

Re: Bug in Perl [OT]

2008-10-10 Thread Jeff Pang
> Message du 10/10/08 13:57 > De : "Mr. Shawn H. Corey" > -- > Just my 0.0002 million dollars worth, > Shawn > > Linux is obsolete. > -- Andrew Tanenbaum > Shawn, I just ask out of curiosity, your signature said: "Linux is obsolete." So what's a popular OS at this time? For myself I use L

Re: Bug in Perl

2008-10-10 Thread Mr. Shawn H. Corey
On Fri, 2008-10-10 at 13:27 +0200, Dr.Ruud wrote: > Deviloper schreef: > > > while ($i < 0.8) { > > #do something which changes $i > > } > > Huh? That can easily still do one too much. Yes, that's the problem the OP was complaining about. Try: #!/usr/bin/perl use strict; use warnings; my

Re: Bug in Perl

2008-10-10 Thread Dr.Ruud
Deviloper schreef: > while ($i < 0.8) { > #do something which changes $i > } Huh? That can easily still do one too much. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Bug in Perl

2008-10-10 Thread Deviloper
or to be nearer to what he/she wanted to do just: while ($i < 0.8) {  #do something which changes $i } "Dr.Ruud" <[EMAIL PROTECTED]> hat am 10. Oktober 2008 um 11:27 geschrieben: > Rob Dixon schreef: > > anilfunde > > >>   for($i=0;$i<0.8;$i=$i+0.1) > >>      { > >>         print "$i\n"; > >> 

Re: Bug in Perl

2008-10-10 Thread Dr.Ruud
Rob Dixon schreef: > anilfunde >> for($i=0;$i<0.8;$i=$i+0.1) >> { >> print "$i\n"; >> } > > The correct way to write this is > > for (0 .. 8) { > my $i = $_/8; > print "$i\n"; > } YM /10. Alternative: for my $p (0 .. 8) { printf "%.1f\n", $p / 10; }

Re: Bug in Perl

2008-10-10 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > Hi All, i found this as a Bug in Perl nO, yoU found this as a buG in yoU. > isn't it a Joke Indeed, it isn't. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-ma

Re: Bug in Perl

2008-10-07 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > Hi All, i found this as a Bug in Perl > > consider > for($i=0;$i<0.4;$i=$i+0.1) > { > print "$i\n"; > } > > > here you wiil get output as expected... > 0 to 0.3 > it work fine

Re: Bug in Perl

2008-10-07 Thread Jenda Krynicky
From: [EMAIL PROTECTED] > Hi All, i found this as a Bug in Perl > > consider > for($i=0;$i<0.4;$i=$i+0.1) > { > print "$i\n"; > } > > > here you wiil get output as expected... > 0 to 0.3 > it work fine till test

Re: Bug in Perl

2008-10-07 Thread Paul Johnson
On Tue, Oct 07, 2008 at 03:07:17PM +0200, Rob Coops wrote: > On Tue, Oct 7, 2008 at 2:45 PM, <[EMAIL PROTECTED]> wrote: > > > Hi All, i found this as a Bug in Perl > > isn't it a Joke > Is that a bug in Perl really? Or is it just that floating point opera

Re: Bug in Perl

2008-10-07 Thread Rob Coops
On Tue, Oct 7, 2008 at 2:45 PM, <[EMAIL PROTECTED]> wrote: > Hi All, i found this as a Bug in Perl > > consider >for($i=0;$i<0.4;$i=$i+0.1) > { >print "$i\n"; >} > > > here you wiil get output as expected... > 0 t

Bug in Perl

2008-10-07 Thread anilfunde
Hi All, i found this as a Bug in Perl consider for($i=0;$i<0.4;$i=$i+0.1) { print "$i\n"; } here you wiil get output as expected... 0 to 0.3 it work fine till test is $i<0.7...UPTO HERE EVERYTHING IS GOING RIGHT BUT magic starts here for($i=0;

Re: bug in perl or in my head ;-)

2007-06-20 Thread Martin Barth
Thank you I learnt a lot! Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: bug in perl or in my head ;-)

2007-06-19 Thread Dr.Ruud
Martin Barth schreef: > [use encoding] > If I understand you right, following code should allways create a utf8 > encoded file. No, "use encoding" is about the encoding of your script, not about file IO. encoding - allows you to write your script in non-ascii or non-utf8 > Since my inputfile

Re: bug in perl or in my head ;-)

2007-06-19 Thread Martin Barth
Hi jay, > You haven't told us what Perl thinks the encoding of the first file > is. how can I do that? > file is a system command that makes use of number of different > approaches to determine file type including, on some systems, I think > it even makes use of metadata. Actually examinin

Re: bug in perl or in my head ;-)

2007-06-19 Thread Jay Savage
On 6/18/07, Martin Barth <[EMAIL PROTECTED]> wrote: Hi there, have a look at: % cat datei eine test datei die "u "a "o % file datei datei: ASCII text % cp datei datei.bk % perl -wpi -e 'use encoding "utf8"; s/"a/ä/' datei % file datei datei: ISO-8859 text % perl -wp -e 'use encoding "utf8"; s/"

Re: bug in perl or in my head ;-)

2007-06-19 Thread Martin Barth
> Probably. It's worth a bug report, at least. I sent it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: bug in perl or in my head ;-)

2007-06-18 Thread Tom Phoenix
On 6/18/07, Martin Barth <[EMAIL PROTECTED]> wrote: I'm a bit confused. Both files should be utf8?? Probably. It's worth a bug report, at least. Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] htt

bug in perl or in my head ;-)

2007-06-18 Thread Martin Barth
Hi there, have a look at: % cat datei eine test datei die "u "a "o % file datei datei: ASCII text % cp datei datei.bk % perl -wpi -e 'use encoding "utf8"; s/"a/ä/' datei % file datei datei: ISO-8859 text % perl -wp -e 'use encoding "utf8"; s/"a/ä/' datei.bk > datei.neu % file datei.neu datei.neu:

Re: a Bug in PERL

2002-12-03 Thread Jenda Krynicky
From: Paul Johnson <[EMAIL PROTECTED]> > On Tue, Dec 03, 2002 at 04:40:37PM +0100, Jenda Krynicky wrote: > > [ Rearranging slightly to get your summary first ] > > > The documentation says you should not do it. Not because it would be > > that hard to say what happens (once you understand what di

Re: a Bug in PERL

2002-12-03 Thread Paul Johnson
On Tue, Dec 03, 2002 at 04:40:37PM +0100, Jenda Krynicky wrote: [ Rearranging slightly to get your summary first ] > The documentation says you should not do it. Not because it would be > that hard to say what happens (once you understand what did I say > above), but because it would be easy to

Re: a Bug in PERL

2002-12-03 Thread david
Pradeep Goel wrote: > $ in NO case a language changes its behaviour for an array with 1 > element > & the same code with array of 2 or more elements ( what the PERL is doing > here ) > it does pops out if last element also happens to be the only element of > array. >> You are correct tha

Re: a Bug in PERL

2002-12-03 Thread Jenda Krynicky
> > PRADEEP GOEL said: > > > If i am not wrong somewhere , there is a bug come to my notice , > > > in PERL > > > > > > @lastnotpop = > > > ("where_gone_me","remaining_is_alright","no_fear_now"); foreach > > > $faltu (@lastnotpop) #$faltu is extra doesn't makes difference > > > even if removed { $

Re: a Bug in PERL

2002-12-03 Thread Jenda Krynicky
From: "PRADEEP GOEL" <[EMAIL PROTECTED]> > $ in NO case a language changes its behaviour for an array > with 1 element & the same code with array of 2 or more elements ( what > the PERL is doing here ) it does pops out if last element also happens > to be the only element of array. Differ

Re: a Bug in PERL

2002-12-03 Thread wiggins
> > > I am really sorry if I am appearing offensive , > I never meant to be . Nope just curious I take it... > In perlsyn documen it does says " Don't do that " else it will get " > confused" > & quite below it says a C programmer does this - while same can be written > in perl as this > ( a

Re: a Bug in PERL

2002-12-03 Thread Rob Dixon
- Original Message - From: "PRADEEP GOEL" <[EMAIL PROTECTED]> To: "Paul Johnson" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, December 03, 2002 12:57 PM Subject: Re: a Bug in PERL > > > > Patient: Doctor, it hurts when

Re: a Bug in PERL

2002-12-03 Thread PRADEEP GOEL
- Original Message - From: "PRADEEP GOEL" <[EMAIL PROTECTED]> To: "Paul Johnson" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, December 03, 2002 6:27 PM Subject: Re: a Bug in PERL > > - Original Message - > From: &

Re: a Bug in PERL

2002-12-03 Thread Paul Johnson
PRADEEP GOEL said: >> > & also that any programming language must follow some sure >> mathematical >> > rules & should not get confused . >> >> The rule is "don't do that". Most languages have rules like that for >> various situations. In C, for example, a statement such as i = i++ is >> unede

Re: a Bug in PERL

2002-12-03 Thread PRADEEP GOEL
- Original Message - From: "Paul Johnson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, December 03, 2002 5:13 PM Subject: Re: a Bug in PERL > > PRADEEP GOEL said: > > > > - Original Message --

Re: a Bug in PERL

2002-12-03 Thread Paul Johnson
PRADEEP GOEL said: > > - Original Message - > From: "Paul Johnson" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Monday, December 02, 2002 5:01 PM > Subject: Re: a Bug in PERL > > >> >> P

Re: a Bug in PERL

2002-12-02 Thread PRADEEP GOEL
- Original Message - From: "Christopher D.Lewis" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, December 02, 2002 8:34 PM Subject: Re: a Bug in PERL > Perhaps what the user intends is a WHILE loop. > > while (@las

Re: a Bug in PERL

2002-12-02 Thread PRADEEP GOEL
- Original Message - From: "Paul Johnson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, December 02, 2002 5:01 PM Subject: Re: a Bug in PERL > > PRADEEP GOEL said: > > If i am not wrong somewhere , th

Re: a Bug in PERL

2002-12-02 Thread Christopher D . Lewis
Perhaps what the user intends is a WHILE loop. while (@lastnotpop) { $current_element = pop(@lastnotpop); print "Just Popped $current_element\n"; } This does what you want via pop. For a while loop, leave the array as it is, and just iterate through it. Enjoy, Chris On Monday, December 2, 200

Re: a Bug in PERL

2002-12-02 Thread Paul Johnson
PRADEEP GOEL said: > If i am not wrong somewhere , there is a bug come to my notice , in PERL > > @lastnotpop = ("where_gone_me","remaining_is_alright","no_fear_now"); > foreach $faltu (@lastnotpop) #$faltu is extra doesn't makes difference > even if removed > { $pch = pop(@lastnotpop ); > print

a Bug in PERL

2002-12-02 Thread PRADEEP GOEL
If i am not wrong somewhere , there is a bug come to my notice , in PERL @lastnotpop = ("where_gone_me","remaining_is_alright","no_fear_now"); foreach $faltu (@lastnotpop) #$faltu is extra doesn't makes difference even if removed { $pch = pop(@lastnotpop ); print " \n can't pop last one from @