Ask your own question, for FREE!
Computer Science 7 Online
myininaya (myininaya):

what is the c++ way of saying (float)Math

OpenStudy (anonymous):

What are you trying to say with "(float)Math"?

myininaya (myininaya):

cosu=(float)Math.cos(u) this is in java how do i say this in c++

myininaya (myininaya):

//outer loop iterates over u u = -M_PI; for (i = nsides - 1; i >= 0; i--) { cosu = (float)Math.cos(u); sinu = (float)Math.sin(u); cosudu = (float)Math.cos(u+du); sinudu = (float)Math.sin(u+du); //the inner loop iterates over v v = -M_PI / 2.0f; for (j = rings; j >= 0; j--) { cosv = (float)Math.cos(v); sinv = (float)Math.sin(v); cosvdv = (float)Math.cos(v+dv); sinvdv = (float)Math.sin(v+dv);

myininaya (myininaya):

i'm trying to convert java to c++

OpenStudy (anonymous):

http://www.cplusplus.com/forum/general/16048/ Looks like you #include <math.h> then you just use global functions sin() and cos().

myininaya (myininaya):

i already have that header

myininaya (myininaya):

i can't get java code to work in c++ i wish there was a program translator between the two lol

OpenStudy (anonymous):

Did you try sinu = sin(u); or maybe sinu = (float)sin(u); I don't know all the details of math.h, but you can google it and I'm sure find lots of info. Specifically the function prototypes (parameters and return types).

OpenStudy (anonymous):

Porting one language to another is not trivial. Writing C++ is especially not trivial. Porting something to C++ will be a challenge. Good luck!

myininaya (myininaya):

thanks for thinking for me lol i'm totally clueless about programming its a course required for my phd they make you take an advanced programming class and i have no experience lol

myininaya (myininaya):

thank god i only have to take one computer class

OpenStudy (anonymous):

Wow. You have to do C++ with no experience? That is...horrifying. You'll need more than luck.

myininaya (myininaya):

lol c++ with open GL

myininaya (myininaya):

there is one computer science person in the class the rest of us are pure math people

OpenStudy (anonymous):

Well, I am absolutely positive that programming would be a good skill for any mathematician. Maybe not C++, but something like python at least.

myininaya (myininaya):

maybe

myininaya (myininaya):

thanks again for your help

OpenStudy (anonymous):

np

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!