Hi,
I've written a program in C++ Builder 6, in order to generate a code for PSpice software. In this code I've used a for loop like this:
Code:
for (double i=deltax/2; i<Lx; i=i+deltax)
{
Memo1->Lines->Add("** i= " + (AnsiString)i);
}
deltax and Lx are doubles. My problem is that after some iterations, the value of i increases by a very small extent and this small error is troublesome for me. for example when I expect i=12.08, it says i=12.08000000000001.
As a solution, I want i to have only 2 digits as decimals. How can I write this?