0

why does pow() return 99... numbers?

When I write own my own Power function it works. Can somebody explain this to me?

   #include <iostream>
   #include <cmath>
   using namespace std;

   int main()
   {
       int bin = 0;
       int tab[3];
       tab[0]=1;
       tab[1]=0;
       tab[2]=1;
       for(int i=0;i<3;i++)
       {
          bin = bin + tab[3-1-i]*pow(10,3-1-i);
          cout << bin << endl;
       }

       return 0;
}
mas4
  • 989
  • 1
  • 8
  • 20
Piotr K.
  • 95
  • 1
  • 2
  • 9

0 Answers0