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:
printf "%.2f", $x;
or
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;
>>
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
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
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
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
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
> >
> >
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-mail: [EMAIL PROTECTED]
http://learn.
[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
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
>
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
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
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
29 matches
Mail list logo