473,394 Members | 1,696 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,394 software developers and data experts.

bool equation

for c++ stl, is there any container or algorithm that can help
calculate result of a bool expression?

e.g.
input: 1&&~0&&0||1
output: 1
Aug 10 '08 #1
2 1641
On Aug 9, 8:45*pm, thomas <FreshTho...@gmail.comwrote:
for c++ stl, is there any container or algorithm that can help
calculate result of a bool expression?

e.g.
input: *1&&~0&&0||1
output: 1
Did you try just that?

int main()
{
bool answer = 1&&~0&&0||1; // Ta Da!
// that's it.
}

you could be cute and even get this answer printed to your screen at
compile time. (i.e. you don't even have to run the program).

something like:

template<typename A>
class Answer {
private:
Answer(){}
};

int main()
{
const bool answer = 1&&~0&&0||1;
Answer<answeris;
}

The answer will appear in the error message you receive trying to
compile the program.
Joe Cook
Aug 10 '08 #2
thomas wrote:
for c++ stl, is there any container or algorithm that can help
calculate result of a bool expression?

e.g.
input: 1&&~0&&0||1
output: 1
No, not in standard C++. You'd have to write a simple parser.

--
Ian Collins.
Aug 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sven Dzepina | last post by:
Hello people =) Has somebody a nice script, which can solve equations ? It would be super, if someone has an idea where I can get such a script / code in php. Thanks. Gretting!
1
by: Russell Blau | last post by:
This is not really a Python question, but it does relate to a Python program I'm working on, so this seems like as good a place as any to ask for suggestions ... I'm working on a GUI application...
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...
9
by: Stud Muffin | last post by:
Hey Basically, I'm trying to take objects created in microsoft word using equation editor (for creating clean looking math/physics equations) and putting them into some sort of webpage format....
5
w33nie
by: w33nie | last post by:
My table is pretty well complete, but I would prefer it if the value for Points could be turned into a mathematical equation, and this equation would use the data from the other fields in the table...
6
by: Trev17 | last post by:
Hello, I am new to C++ and i have tried for several hours to make a program my teacher has given me as a lab. Here is the Lab question: the roots of the quadratic equation ax^2 + bx + c = 0, a...
6
by: trashman.horlicks | last post by:
Hi, A few months ago, I saw an equation parser, written in c#, and using regular expressions (I think!), but now I cannot recall where I saw it- if anyone saw anything like this, could they please...
10
by: Constantine AI | last post by:
Hi i am having a little problem with an equation function that was created from all your help previously. The function works fine itself but with a small glitch within it. Here is the function...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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 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.