in reply to Re: printf rounding issue
in thread printf rounding issue

I am doing same thing as mentioned in the thread .
$val = $val * 100 ; $val = $val / 100;
This is the reason I am getting correct value when I am printing on screen with print . My issue is why I am getting different values when I am using print and printf . Also what is the solution to print value correctly in FILE .

Replies are listed 'Best First'.
Re^3: printf rounding issue
by LanX (Saint) on Nov 16, 2016 at 14:07 UTC
    > I am doing same thing as mentioned in the thread .
    $val = $val * 100 ; $val = $val / 100;

    from the thread:

    The shift must be a string operation. Dividing by 100 reintroduces the problem with floats!

    edit

    > My issue is why I am getting different values when I am using print and printf

    as Eily already told you, you are rounding in printf at the second position not the third.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!