Home » General Discussions » General Discussion » OT: C++ Recursion
|
Re: OT: C++ Recursion [message #192148 is a reply to message #192146] |
Tue, 07 March 2006 20:42   |
 |
Dave Anderson
Messages: 1953 Registered: December 2004 Location: United States
Karma: 0
|
General (1 Star) |
|
|
I don't have any of my C++ programming books anymore, and I forgot what the % operator stands for. If you can tell me that, I may be able to figure it out.
EDIT: Nevermind, I remember now. the % operator is a modulus. Example: int rem = 4 % 3;
Of course you probobly already know that...lol. I will further try to figure this out.
What are your thoughts on this so far?
David Anderson
Founder, Software Consultant
DCOM Productions
Microsoft Partner (MSP)
[Updated on: Tue, 07 March 2006 20:52] Report message to a moderator
|
|
|
|
|
Re: OT: C++ Recursion [message #192156 is a reply to message #192146] |
Tue, 07 March 2006 21:56   |
 |
Ryan3k
Messages: 363 Registered: September 2004 Location: USA
Karma: 0
|
Commander |
|
|
CPUKiller has pretty much got it, I don't know C++ myself, but I know Java, and all you need to know is that the '%' operator is for modular division, and it gives you the remainder of a/b.
For example,
10 % 3 = 1
10 % 10 = 0
12 % 5 = 2
Another important note is that because it is an int, it will truncate decimals. In the first runthrough of ValueOf, when you divide 11 by 2, you get 5.5, right? Well, it won't round it up to 6. It truncates the decimal, and you end up with 5.
5 becomes the new 'N', passed as parameter to ValueOf... etc. etc.
|
|
|
|
|
|
Re: OT: C++ Recursion [message #192162 is a reply to message #192146] |
Tue, 07 March 2006 23:20   |
 |
Dave Anderson
Messages: 1953 Registered: December 2004 Location: United States
Karma: 0
|
General (1 Star) |
|
|
Well, seems that I have learned a thing or two from this topic:
Quote: | For example,
10 % 3 = 1
10 % 10 = 0
12 % 5 = 2
|
I thank you very much for refreshing my memory. 
EDIT: Since this is the same subject, I just wanted to let y'all know that when I finish my website, (which is taking forever because it gets boring at times), I will have a complete section on C++ where you can go if you want to learn the basics of C++. It will be pretty explanatory and should be pretty straight foward. When I first learned C++, I pretty much went to my local library, checked out a C++ book, and was writing very basic programs within the hour I started reading.
My object for providing this section on my site, is I am hoping that others interested in C++ can use what I have learned to learn it themselves.
David Anderson
Founder, Software Consultant
DCOM Productions
Microsoft Partner (MSP)
[Updated on: Tue, 07 March 2006 23:25] Report message to a moderator
|
|
|
|
Re: OT: C++ Recursion [message #192217 is a reply to message #192146] |
Wed, 08 March 2006 15:32   |
 |
Sir Kane
Messages: 1701 Registered: March 2003 Location: Angerville
Karma: 0
|
General (1 Star) |
|
|
Wonder what happens if you __forceinline that function lol
Proud N9500 and proud N6270 user. Creator of the IEE libraries (original bhs.dll) and the RB series software.

|
|
|
Re: OT: C++ Recursion [message #192228 is a reply to message #192217] |
Wed, 08 March 2006 19:03  |
=HT=T-Bird
Messages: 712 Registered: June 2005
Karma: 0
|
Colonel |
|
|
Silent Kane wrote on Wed, 08 March 2006 16:32 | Wonder what happens if you __forceinline that function lol
|
If the argument was a constant-expression, I'd say that most sensible compilers capable of unit-at-a-time compilation would be able to evaluate the entire mess at compile time (it's a pure function).
HTT-Bird (IRC)
HTTBird (WOL)
Proud HazTeam Lieutenant.
BlackIntel Coder & Moderator.
If you have trouble running BIATCH on your FDS, have some questions about a BIATCH message or log entry, or think that BIATCH spit out a false positive, PLEASE contact the BlackIntel coding team and avoid wasting the time of others.
|
|
|
Goto Forum:
Current Time: Sun Apr 06 06:16:51 MST 2025
Total time taken to generate the page: 0.00795 seconds
|