Code::Blocks Forums

User forums => Help => Topic started by: sarunas10 on March 05, 2015, 05:10:15 pm

Title: Power problem
Post by: sarunas10 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?
Title: Re: Power problem
Post by: scarphin 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.
Title: Re: Power problem
Post by: sarunas10 on March 05, 2015, 05:44:57 pm
I'm sorry, I'm kind of a new member here, didn't know.
Title: Re: Power problem
Post by: Jenna 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 (http://forums.codeblocks.org/index.php/topic,9996.0.html) 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.