473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

String math equation to actual numbers

Hi!

I need to interpret a string which contains a mathematical expression and get from it a double value. For example:

from the string "(2+2)^2" get the value 16 (as integer or double)

I prefer to use an existant method rather than writting my own interpreter if possible. Any ideas?

thanks!
Aug 1 '07 #1
2 1092
Hi!

I need to interpret a string which contains a mathematical expression and get from it a double value. For example:

from the string "(2+2)^2" get the value 16 (as integer or double)

I prefer to use an existant method rather than writting my own interpreter if possible. Any ideas?

thanks!
There must be a something like available.. google calculator for example already does this anyway.. when we type 2+2 it returns 4.
Aug 1 '07 #2
kenobewan
4,871 Expert 4TB
Here is an article that may help:
Digging Into CalcPad
Aug 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Frank Millman | last post by:
Hi all I was helping my niece with her trigonometry homework last night. Her calculator's batteries were flat, so I thought I would use Python's math module to calculate sin, cos, and tan. I...
89
by: Radioactive Man | last post by:
In python 2.3 (IDLE 1.0.3) running under windows 95, I get the following types of errors whenever I do simple arithmetic: 1st example: >>> 12.10 + 8.30 20.399999999999999 >>> 1.1 - 0.2...
1
by: qwweeeit | last post by:
Another math problem easier to solve by hand, but, IMHO, difficult to program in a concise way like the solution of Bill Mill (linalg_brute.py) to the problem of engsol. I appreciated very much...
20
by: Brian Kazian | last post by:
Here's my problem, and hopefully someone can help me figure out if there is a good way to do this. I am writing a program that allows the user to enter an equation in a text field using...
4
by: TS | last post by:
I have this simple equation that returns a boolean: if( ti.NumberIncorrect > (TotalQuestions - (TotalQuestions * FailurePercentage) )) ti.NumberIncorrect is int : 4 TotalQuestions is int :...
28
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
9
by: Bob M | last post by:
If I define an expression or equation, how can I retrieve that expression as string literal? I want to do this so that I could avoid repetitive typing (or copy/paste/change) the same thing at two...
1
by: Andrew Lee | last post by:
Mensanator wrote: Heh! I wonder who needs that many digits? Certainly not number theorists (they need a LOT more). Certainly not physicists -- they need about 30 digits to be within 1%...
2
by: phoenix1990 | last post by:
so i have an entry frame where i want to input an equation, and i need to turn the string into an actual equation in terms of x. so that i can plot it on a canvas. i already know how to make the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.