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
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
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
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
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
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
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
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
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
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
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
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
> >
> >
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
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
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
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.
> 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
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
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/
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";
> >>
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;
}
[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
[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
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
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
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
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;
Thank you
I learnt a lot!
Martin
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
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
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
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/"
> 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/
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
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:
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
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
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
> > 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 { $
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
> >
> 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
- 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
- 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: &
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
- 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 --
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
- 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
- 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
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
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
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 @
50 matches
Mail list logo