[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Looking for (KDE) lib/class to perform calculations
From:       George Staikos <staikos () kde ! org>
Date:       2002-03-25 2:31:22
[Download RAW message or body]

On Sun, 24 Mar 2002, ian reinhart geiser wrote:

> Ah that is very easy, almost every book on the STL in the chapter on stacks
> tells how to do this.  I think I have code for that rolling arround here for
> that too, it does all *./,-,+ and handles () properly, i think it even will
> do ^ too, but i forget.  There is lose support for variables but I never
> really needed it to handle more than two variables at a time so I hard coded
> it.  (It was for a random variat generator)

This is also very easy (and probably lighter) to do with yacc.  However
the problem remains of how useful this is if it doesn't provide guarantees
about numerical precision, available operations, etc.  I don't see why
this should go into kdecore.  We could have libkdemath or something to
that effect, but a proper implementation of this (read: full
implementation) could get quite heavy and require platform-specific
adjustments (especially due to different implementations of floats).  I
think it would be great to have a bignum class, and then have the ability
to apply the operations to either bignum, float, or int as necessary.

This still all seems to be out of the scope of KDE though.  There are so
many libraries which already do this, and they are written by people who
understand the pitfalls.  BC is probably a great candidate for a library
which does much of tihs.  There is also octave, and gmp.

If you just want something simple to parse and evaluate basic algebraic
instructions using floats, you might as well create a parser with
yacc/bison, and you can even write the scanner by hand.  If you check out
the Bison manual, you will see that this is the exact example they use in
the tutorial.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic