Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Write the source code
Index -> C++
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bbi5291




PostPosted: Mon Aug 31, 2009 8:27 pm   Post subject: Re: RE:Write the source code

saltpro15 @ Mon Aug 31, 2009 8:03 am wrote:
Nice. My only recommendation is to use a longer value of Pi, as really, really big numbers could give you precision errors. I like to use the first 9 digits.

You can use M_PI, a macro defined in math.h / cmath, or acos(-1.0) (the latter looks cooler, but I think it returns a double, so if you want a long double pi, then you're not taking advantage of all the bits of precision... I may be wrong though)
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Mon Aug 31, 2009 8:27 pm   Post subject: Re: Write the source code

Out of curiosity, how do you register your own operators? For example I have a vector class, and I want to use "cross" as an operator, so I can do something like: A cross B; or A cross= B;
bbi5291




PostPosted: Mon Aug 31, 2009 8:28 pm   Post subject: Re: Write the source code

CodeMonkey2000 @ Mon Aug 31, 2009 8:27 pm wrote:
Out of curiosity, how do you register your own operators? For example I have a vector class, and I want to use "cross" as an operator, so I can do something like: A cross B; or A cross= B;

You can't. Not in C++.

(I wanted to edit my previous post to say that acos(-1.0l) works)
A.J




PostPosted: Mon Aug 31, 2009 8:40 pm   Post subject: Re: RE:Write the source code

@jhooper

Use the following tag:

[syntax='cpp']

Code goes here

[/syntax]

(except that you would replace the single quotes around cpp to double quotes)
saltpro15




PostPosted: Mon Aug 31, 2009 8:40 pm   Post subject: (No subject)

jhooper3581 @ Mon Aug 31, 2009 wrote:
How do you guys use that type of code typing posting in this forum? (Colored texts, et cetra).



use syntax tags

code:
[syntax=" "][/syntax]


insert language in between the brackets, cpp for C++
DtY




PostPosted: Mon Aug 31, 2009 8:40 pm   Post subject: Re: Write the source code

bbi5291 @ Mon Aug 31, 2009 8:24 pm wrote:
I guess there really was no reason to introduce a new math library in C++. You can't add templates, since the math functions are coded in assembly. (I suppose I/O does get a new library because there's much more room for flexibility)

Actually, now that I think about it, I remember reading that all the functions in math.h that use floating point numbers (all of them?) are overloaded to take in a float, double or long double, and return the same type (whereas they all take just double in C), so I guess <cmath> is different than <math.h>, or the compiler just automatically overloads them.
andrew.




PostPosted: Mon Aug 31, 2009 11:42 pm   Post subject: Re: RE:Write the source code

insectoid @ Mon Aug 31, 2009 8:20 am wrote:
Is ^ not a function in C++? I notice you use pow(x, 2) which I assume means x^2. How hard IS it to put that into a language? (Or is it already reserved for a different command?)
It's like that in Java as well.
jhooper3581




PostPosted: Mon Aug 31, 2009 11:55 pm   Post subject: (No subject)

Thanks, guys!
Display posts from previous:   
   Index -> C++
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 23 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: