× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: cube root by way of Robin Hood's barn was RE: Cube root
  • From: Joel Fritz <JFritz@xxxxxxxxxxxxxxxx>
  • Date: Mon, 26 Feb 2001 11:25:53 -0800

So, I guess it all depends on what you think is simple.  Shortly after
posting this and after I found that the list server was down I realized that
there was a method that was a bit simpler than the one below.  I'll bet
there are more than a few posts that recommend the 1/3 power method. <g> 

> -----Original Message-----
> From: Joel Fritz [mailto:JFritz@sharperimage.com]
> Sent: Friday, February 16, 2001 8:07 AM
> To: 'RPG400-L@midrange.com'
> Subject: RE: Cube root
> 
> 
> The simplest thing would probably be using the C math library 
> functions,
> although you could write a small procedure that would use 
> Newton's method or
> some similar algorithm to whatever degree of precision you desire.  
> 
> I'd have to dig out an old textbook to remember the details 
> of Newton's
> method, but with logarithms you find the log of the number, 
> divide it by
> three and calculate the log base to the power of the 
> logarithm you just
> calculated. The RPG code (after you'd prototyped the log function and
> assuming you use base 10 logs) would be:   eval cube_root =
> 10**(log10(number)/3).  The number whose log you take has to 
> be a float and
> the cube root returned will be a float.  
> 
> I think the prototype would be something like the following although I
> haven't tested it:
> 
>  Dlog10            pr             8f   extproc('log10')    
>  D number                         8f                       
> 
> You'd need to reference binding directory QC2LE to make the C library
> functions visible. 
> 
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.