Ajay Kumar <akumar@securities.com> asked: > Gesendet: Freitag, 21. August 2009 12:23 > An: beginners@perl.org > Betreff: RE: WELCOME to beginners@perl.org > > Hi All > > I have great issues > > 1) perl -e '$a=0.123451005;$a=sprintf("%.8f",$a);print"=$a\n";' > Output=0.12345101 > 2) perl -e '$a=5.123451005;$a=sprintf("%.8f",$a);print"=$a\n";' > Output=5.12345100 > > > Here 1 one ging correct result but the second one wrong result > For second one result should be 5.12345101 but it is giving 5.12345100 > > > May I know why it behabe So See the first question in the Data: Number section of http://perldoc.perl.org/perlfaq4.html For the gritty details, see the article http://en.wikipedia.org/wiki/Floating_point and especially its setion "representable numbers" at Wikipedia. HTH, ThomasThread Previous