Hi! My problem is that im trying to make an Int out of the string a=X+Y*Z-A/B... (for example 1-2+6-3*2/3-3). when i do Int(a) it doesn't work beacuse of the (+,-,/,*)
What should i do?
6 4050 bvdet 2,851
Recognized Expert Moderator Specialist
Hi! My problem is that im trying to make an Int out of the string a=X+Y*Z-A/B... (for example 1-2+6-3*2/3-3). when i do Int(a) it doesn't work beacuse of the (+,-,/,*)
What should i do?
Would something like this work for you? - x,y,z,w = 3.0,12,16,4.5
-
a='x+y*z-w/x'
-
print eval(a)
-
print int(eval(a))
-
Yes... thank you very much
bartonc 6,596
Recognized Expert Expert
Would something like this work for you? - x,y,z,w = 3.0,12,16,4.5
-
a='x+y*z-w/x'
-
print eval(a)
-
print int(eval(a))
-
or get the floating point (since they're in the formula) by:
What if i want the calculation to skip the usual rules, so that x+y*z-a/b is like ((((x+y)*z)-a)/b)?
bartonc 6,596
Recognized Expert Expert
What if i want the calculation to skip the usual rules, so that x+y*z-a/b is like ((((x+y)*z)-a)/b)?
Use the parens in the string or break it up and eval pieces at a time.
Sounds like you're working on some sort of language parser...
What's the project about? One of my early projects was an assembler for moto micros. Keep posting,
Barton
Im making a dicegame. I'm an absoulte beginner and i am not very good with computers, so a am very thankful for your help!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eric Lilja |
last post by:
Hello, I've made a templated class Option (a child of the abstract base
class OptionBase) that stores an option name (in the form someoption=) and
the value belonging to that option. The value is...
|
by: Jon |
last post by:
I want to count the number of instances of a certain string(delimiter) in
another string. I didn't see a function to do this in the framework (if
there is, please point me to it). If not, could...
|
by: Niyazi |
last post by:
Hi
I have a report that I have to run it monthly in my machine.
My code in VB.NET and I access AS400 to get data, anaysie it and send into
pre formated Excel sheet. The data consist of 9000...
|
by: beachboy |
last post by:
My project has many class (function), it need to create a new instance each
time by the id value, how can i write a code as much simple?
Actually, all cases is doing the same thing.... , but is...
|
by: Scott M. |
last post by:
Ok, this is driving me nuts...
I am using VS.NET 2003 and trying to take an item out of a row in a
loosely-typed dataset and place it in a label as a currency. As it is now,
I am getting my...
| |
by: zzw8206262001 |
last post by:
Hi,I find a way to make javescript more like c++ or pyhon
There is the sample code:
function Father(self) //every contructor may have "self"
argument
{
self=self?self:this; ...
|
by: carly |
last post by:
Hi all,
I have been working on a quesstion, i have solved parts a up to c, but im having trouble with part d and e, any tips on how i can solve them would be very much appreaciated. I'd also...
|
by: V S Rawat |
last post by:
I was trying to use back-to-back replace functions to convert a url:
str1 =
str.replace("%2F","/").replace("%3F","?").replace("%3D","=").replace("%2
6","&");
It didn't replace all 4 types of...
|
by: Mikael Syska |
last post by:
Hi,
I have a problem ...:
If you look at http://syska.dk/upload/eb-14.jpeg you can see some names
to the right ... Alexandro, syska, resurrected.
I want an option to pick a new color for the...
|
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,...
|
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...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |