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: printf "%.2f", $x; or

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 off the number before printing. In Perl: >> >> printf "%.2f", $x; >>

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, thank you all for your help. Octavian

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, Shawn Programming is a

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
From: "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 o

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 > > > >

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-mail: [EMAIL PROTECTED] http://learn.

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 till test is $i<0.7...UPTO HERE EVERYTHING IS GOING > RIGHT

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 is $i<0.7...UPTO HERE EVERYTHING IS GOING > RIGHT >

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 operations > are never exact and this deviatio

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 to 0.3 > it work fine till test is $i<0.7...UPTO HERE EV

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