User forums > Help
Power problem
(1/1)
sarunas10:
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?
scarphin:
--- Quote from: sarunas10 on March 05, 2015, 05:10:15 pm ---What's the problem?
--- End quote ---
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.
--- End quote ---
Before moderators lock this topic, I suggest you consult a general programming board for these kind of questions.
sarunas10:
I'm sorry, I'm kind of a new member here, didn't know.
Jenna:
--- Quote from: sarunas10 on March 05, 2015, 05:44:57 pm ---I'm sorry, I'm kind of a new member here, didn't know.
--- End quote ---
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.
Navigation
[0] Message Index
Go to full version