Author Topic: Power problem  (Read 2862 times)

Offline sarunas10

  • Single posting newcomer
  • *
  • Posts: 3
Power problem
« on: March 05, 2015, 05:10:15 pm »
Hello,
I have a little problem with powers. Here's my code:
"int limit2=0;
for(int i=0;i<6;i++){
            limit2+=pow(10,i);
    }
cout<<limit2;"
The outcome should be 111111, but for some reason it is 111109. Sometimes (when the power is big) while raising a positive number by power it gives negative result. What's the problem?

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Power problem
« Reply #1 on: March 05, 2015, 05:18:48 pm »
What's the problem?

The problem is your question is against the forum rules, even against the first one:
Quote
1. This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework", "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.

Before moderators lock this topic, I suggest you consult a general programming board for these kind of questions.

Offline sarunas10

  • Single posting newcomer
  • *
  • Posts: 3
Re: Power problem
« Reply #2 on: March 05, 2015, 05:44:57 pm »
I'm sorry, I'm kind of a new member here, didn't know.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Power problem
« Reply #3 on: March 05, 2015, 06:32:15 pm »
I'm sorry, I'm kind of a new member here, didn't know.
When registering here you accepted to follow the forum rules.

And above the "Post" and "Preview" buttons, there is a link:
Please read the rules before you post!

And don't reading this means you are ignorant in my opinion.

Next time you might get banned for a while.

I know this sounds harsh, but is not meant offending.
(Re-)read the rules and try to understand the moderators/admins.