|
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. -----Original Message----- From: Walter Hesius [mailto:Walter.Hesius@Village.uunet.be] Sent: Wednesday, February 14, 2001 1:06 PM To: RPG400-L@midrange.com Subject: Cube root Hi all, I would like to know a way to calculate the cube root of a number. We are on V4R4. Thanx. +--- | 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 mailing list archive is Copyright 1997-2025 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.