Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Visual C++ 2012
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2012 by Ivor Horton; ISBN: 978-1-118-36808-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2012 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2013, 08:25 PM
Registered User
 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default power calculation Ex3_09

Hi,
I'm trying to understand how example program Ex3_09 calculates the powers of the numbers. I think I understand the for loop statement, but what's doing the actual calculating here? Where's the statement that says to take 2 and raise it to each power? Or is it just magic?

Thank You!

Ruben
 
Old June 18th, 2013, 10:37 AM
Registered User
 
Join Date: Jun 2013
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default What calculates the power

From the code, power += power, that's the same as let say 2^2 which is the same as saying 2+2= 4 or 2^2. So its the "power += power" that does it.
 
Old June 18th, 2013, 10:43 AM
Registered User
 
Join Date: Jun 2013
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Power's of Two

Just remember, this is calculating powers of two. I forgot to mention that.
 
Old March 14th, 2014, 09:47 AM
Registered User
 
Join Date: Feb 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unexpected result if power type is changed to unsigned long.

I tried changing the power type to unsigned long and displaying the first 31 powers, but this had the unexpected result that the 31st power was displayed as a negative number (i.e. the variable power was being treated as long).

I found that the only way to get power treated as unsigned long was to declare the iterator i an unsigned long as well.

Why is that?

Last edited by rinpoche; March 14th, 2014 at 09:53 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
for loop Ex3_09 would not compile for me earlmw BOOK: Ivor Horton's Beginning Visual C++ 2005 2 January 22nd, 2010 12:19 PM
Charting in power point using C# amitabha.chakraborty Book: Wrox's Visual C# 2005 Express Edition Starter Kit 0 May 13th, 2009 02:17 AM
GPO and Power Management Sebastiaan VBScript 0 November 21st, 2006 08:10 AM
Power to the Programmers! James C Forum and Wrox.com Feedback 14 June 15th, 2003 10:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.