logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: Mathmatical Question, Formula to multiply a number by smaller amounts?: msg#00192

windows.devel.dotnet.cx

Subject: Re: Mathmatical Question, Formula to multiply a number by smaller amounts?

On Wed, 28 Sep 2005 14:35:08 -0700, Zeusbwr <zeusbwr@xxxxxxxxx> wrote:

>double dMod = 1.05; // Modifier
>double dNumber = 1; // Number i wish to modify
>
>for( int i = 0; i < 5; i++ ){
>
> dNumber = dNumber * dMod;
> Console.Writeline( "Here is your {0} number: {1}, i, dNumber );
> dMod = dMod * 0.95;
>
>}
>
>
>Now what i want to do is exactly that, each iteration i want to
>multiple a number by a ever smaller number. But the thing is, dMod
>cant change.
>
>Would it be possible to accomplish what is done with that loop,
>without modifying dMod?

Well, if I understand you correctly you just need to use powers
(which are essentially repeated multiplications, if the exponent
is an integer).

double dMod = 1.05; // Modifier
double dNumber = 1; // Number i wish to modify

for( int i = 0; i < 5; i++ )
{
dNumber = dNumber * (dMod ^ (i + 1));
Console.Writeline( "Here is your {0} number: {1}, i, dNumber );
}

So, you never modify dMod but you get the same results.
My C++ is rusty so you need to look up the
exact syntax for raising a number to an integer power.
If I recall correctly C(++) has no built-in support for raising
a number to a non-integer power but you don't need that.
(You can work around that by using exp and ln anyway.)

BTW, this is hugely off-topic. In the future you're better off
asking such things in any newsgroup that has "math" in its name
(e.g. comp.sci.math)

HTH

Sven

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    gcc.libstdc++.c...    solaris.opensol...    information-ret...    misc.misterhous...    web.catalyst.ge...    apache.webservi...    redhat.release....    hardware.lirc/2...    kernel.autofs/2...    technology.sust...    linux.vdr/2003-...    editors.lyx.gen...    org.user-groups...    netbsd.devel.pk...    xdg.devel/2004-...    version-control...    jakarta.slide.d...    debian.packages...    creativecommons...    ports.ppc.embed...    bug-tracking.bu...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation