× 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: Re: text equation
  • From: Jim Langston <jlangston@xxxxxxxxxxxxxxxx>
  • Date: Mon, 20 Dec 1999 14:55:33 -0800
  • Organization: Conex Global Logistics Services, Inc.

Hmm... that looks like something Perl would be more
apt at doing.  Perl is great at parsing.

I can see that would be a big program in RPG if you are
looking for all possible cases.  You have to look for the
parenthesis, you have to look at the signs, most mathematical
formulas use sign hierarchy (* and / before + and -) most are
left to right, but some are right to left, etc...

That is, 12 * 10 + 3 / 2 can produce a number of answers,
depending on how you parse it.
61.5 = ((12 * 10) + 3) / 2 = Left to right
121.5 = (12 * 10) + (3 / 2) = Hierarchy
138 = 12 * (10 + (3 / 2)) = Right to left (APL uses this)

and then you get into combinations of hierarchy and left to right
or right to left.  Most interpreters doe them with hierarchy and
Left to Right (such as Visual Basic).  I'm not sure what the
Eval statement does, I would assume the same way.

It doesn't look like a quick program.

Regards,

Jim Langston

Eric Panissard wrote:

> Hi everybody,
>
> I am looking for an RPG sub-program who can recognize and calculate a text
> equation like :
>     (250*(12+45.5))-10
>
> the equation can contain : the 4 basic operation, decimal point, multiple
> parenthesis

<SNIP>

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-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 ...

Replies:

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.