it should give me 22.443, but I am getting 22.4430000000001. It works fine if I use for (1..42) or less than 42 then I get correct value e.g. for (1..42) I get 22.442
So is there limit to run loop? but I never faced such problem before as I run loop many times.

A way around is to start $a as 22400, add 1 to it at each iteration, and remember to divide by 1000 in the end before using the result (or never divide by 1000, but use the result in a way that accounts for the additional factor)

Note that Perl 6 solves the problem by storing 0.001 as a rational number by default.

What are you actually trying to do? What precision (how many digits) do you really need? Moritz provided a good solution (work with integer values then scale as the last step) - what is wrong with that solution?

As an exercise try writing 1/3 as a decimal fraction in full. Let me get you started:

Have you figured out that you can't exactly represent 1/3 as a finite decimal fraction? In the same way you can't exactly represent 1/10 (base 10) as a finite binary fraction. This seems like a problem, but for almost all real applications for arithmetic it is not an issue. You seldom need more than a few digits of precision for an answer (although for some calculations you may need more precision for intermediate answers).

So the key questions are: what are you trying to do and how much precision do you really need? There are many possible ways to solve your problem, but a solution depends very much on what you are trying to achieve.

I need some value upto 3 decimal places and want to use that in calculations. But actually the value becomes 22.430000001 like that. in summary I want that value remains 22.43 just not "nice value" to be 'printed'. yes 22.43 and 22.43000001 are almost same. but I need to extract some data from million number of values (which are three decimal place) from text file. So I need exact decimal place or it will be ignored to be extracted.

>> And if you just want to display it nice, use printf >>"%.3f\n", $a;

So this mean actually number is 22.430000001 which will be used for actual calculations but printf just prints 22.43 just for "nice display". So it will give wrong calculation results because number used will be 22.4300001. should I install PERL6, no solution in PERL5.*?