Click here to Skip to main content
15,922,533 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Dialog Box DDX problem Pin
kitty520-Jul-06 3:47
kitty520-Jul-06 3:47 
GeneralRe: Dialog Box DDX problem Pin
David Crow20-Jul-06 4:22
David Crow20-Jul-06 4:22 
QuestionProblem with the pow( ) function [modified] Pin
KaKa'19-Jul-06 7:29
KaKa'19-Jul-06 7:29 
QuestionRe: Problem with the pow( ) function Pin
David Crow19-Jul-06 7:34
David Crow19-Jul-06 7:34 
AnswerRe: Problem with the pow( ) function Pin
toxcct19-Jul-06 7:35
toxcct19-Jul-06 7:35 
QuestionRe: Problem with the pow( ) function Pin
pgav19-Jul-06 7:37
pgav19-Jul-06 7:37 
AnswerRe: Problem with the pow( ) function Pin
cppcook19-Jul-06 7:42
cppcook19-Jul-06 7:42 
GeneralRe: Problem with the pow( ) function Pin
Zac Howland19-Jul-06 8:41
Zac Howland19-Jul-06 8:41 
cppcook wrote:
If you couldn't figure out the problem, why don't you write your own pow() function? It's simple...


Simple for integer exponents ... not so simple for decimal exponents.

As for the original post, my guess is that you are mixing types (that is, raising a double by an integer power). While there is nothing wrong with that, pow is usually defined:

From MSDN:
double pow(
   double x,
   double y 
);
double pow(
   double x,
   int y
);  // C++ only
double pow(
   int x,
   int y
);  // C++ only
float pow(
   float x,
   float y 
);  // C++ only
float pow(
   float x,
   int y
);  // C++ only
long double pow(
   long double x,
   long double y
);  // C++ only
long double pow(
   long double x,
   int y
);  // C++ only
float powf(
   float x,
   float y 
);


Try explicitly casting your types:

double base = 3.0;
int power = 5;
int result = pow(base, (double)power);


If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac
AnswerAmbiguous call Pin
Ennis Ray Lynch, Jr.19-Jul-06 8:47
Ennis Ray Lynch, Jr.19-Jul-06 8:47 
AnswerRe: Problem with the pow( ) function Pin
NrmMyth19-Jul-06 12:20
NrmMyth19-Jul-06 12:20 
GeneralRe: Problem with the pow( ) function Pin
KaKa'26-Jul-06 22:21
KaKa'26-Jul-06 22:21 
QuestionEdit Box alignment problem Pin
cppcook19-Jul-06 7:24
cppcook19-Jul-06 7:24 
QuestionRe: Edit Box alignment problem Pin
David Crow19-Jul-06 7:32
David Crow19-Jul-06 7:32 
AnswerRe: Edit Box alignment problem Pin
cppcook19-Jul-06 7:36
cppcook19-Jul-06 7:36 
QuestionRe: Edit Box alignment problem Pin
David Crow19-Jul-06 7:49
David Crow19-Jul-06 7:49 
AnswerRe: Edit Box alignment problem Pin
cppcook19-Jul-06 8:00
cppcook19-Jul-06 8:00 
AnswerRe: Edit Box alignment problem Pin
earl19-Jul-06 8:34
earl19-Jul-06 8:34 
QuestionSyntax Question Pin
pgav19-Jul-06 7:14
pgav19-Jul-06 7:14 
AnswerRe: Syntax Question Pin
Justin Tay19-Jul-06 7:17
Justin Tay19-Jul-06 7:17 
AnswerRe: Syntax Question Pin
toxcct19-Jul-06 7:19
toxcct19-Jul-06 7:19 
GeneralRe: Syntax Question Pin
pgav19-Jul-06 7:25
pgav19-Jul-06 7:25 
AnswerRe: Syntax Question Pin
Zac Howland19-Jul-06 8:54
Zac Howland19-Jul-06 8:54 
Questionbrekpointing every function Pin
TClarke19-Jul-06 6:11
TClarke19-Jul-06 6:11 
QuestionWinsocket2 Pin
Jay0319-Jul-06 5:56
Jay0319-Jul-06 5:56 
AnswerRe: Winsocket2 Pin
Zac Howland19-Jul-06 6:06
Zac Howland19-Jul-06 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.