calculator

Simple PHP calculator

ぃ、小莉子 提交于 2019-11-28 21:39:17
I'm creating a basic PHP calculator that lets you enter two values and chose your operator then displays the answer. Everything is working fine except it's not outputting the answer to the browser. Here are the codes for my html and PHP files: <head> <meta charset="utf-8"> <title>Calculator</title> </head> <body> <form method="post" attribute="post" action="disp_form.php"> <p>First Value:<br/> <input type="text" id="first" name="first"></p> <p>Second Value:<br/> <input type="text" id="second" name="second"></p> <input type="radio" name="group1" id="add" value="add" checked="true"><p>+</p><br/>

Is there a calculator with LaTeX-syntax?

时光怂恿深爱的人放手 提交于 2019-11-28 16:40:19
When I write math in LaTeX I often need to perform simple arithmetic on numbers in my LaTeX source, like 515.1544 + 454 = ??? . I usually copy-paste the LaTeX code into Google to get the result, but I still have to manually change the syntax, e.g. \frac{154,7}{25} - (289 - \frac{1337}{42}) must be changed to 154,7/25 - (289 - 1337/42) It seems trivial to write a program to do this for the most commonly used operations. Is there a calculator which understand this syntax? EDIT: I know that doing this perfectly is impossible (because of the halting problem). Doing it for the simple cases I need

Java Doubles are not good at math [closed]

流过昼夜 提交于 2019-11-28 13:13:50
I am currently writing a calculator program in java. It is my first java program, I am used to c++. I have noticed that doubles in java are not at all like doubles in c++. try this in java and c++ 4.1*3 that/.1 it should be 12.3 then 123, and c++ gives this result but java gives 12.299999999999999 and 122.99999999999999 How can I do math like in c++ with doubles, I understand that anything you would use 12.299999999999999 in a program at all would make no difference compared to 12.3, but when a user is reading the numbers this is very ugly. I have looked into the BigDecimal class but I cannot

Get Back Result from Android native Calculator

血红的双手。 提交于 2019-11-28 11:40:03
问题 I'm invoking android native calculator from my app, how do i get result data from it.. means i started native calender like this, after finishing calculation i press back onActivityResult is executed and data returned is null, how to get calculated data.. Help me Intent i = new Intent(); i.setClassName("com.android.calculator2", "com.android.calculator2.Calculator"); startActivityForResult(i, 1); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super

Calculator Problems - Android Programming

五迷三道 提交于 2019-11-28 11:32:43
问题 I'm trying to design a simple calculator for use as a scoreboard for a game or two. Ultimately, I want to be able to select the number of players, have that many score-trackers appear on screen, be able to use a the touch calculator to add or subtract (or divide or multiply) I got it to work for the most part. Currently, it takes the text inputted in the calculator display, adds/subtracts/whatever that to the player score that I choose. The problem is trying to get the numerical keys to show

Infix Calculator Expression Parser

可紊 提交于 2019-11-28 09:33:50
How do I parse and evaluate expressions in an infix calculator grammar? I thought of two ways. The 1st involves using two stacks. One is for numbers and the other is for operators, and I would assess the operator precedence and association in order to figure out how to evaluate an expression. The second method involves converting the infix expression to postfix which I have no idea how I'd go about doing. It was just an idea. Currently I set up my program with the intention to use the 1st method. #include <iostream> #include <string> #include <sstream> using namespace std; bool die(const

keydown in c# doesn't work for some reason

隐身守侯 提交于 2019-11-28 08:49:12
问题 I'm trying to do a calculator and all I have to do is make it work with the keyboard. This should work but it doesn't. private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.D1) { resultarea.Text = "fgdgd"; //number(1); } .... } Any idea what could have gone wrong? Edit: it's still not working. I figured I might aswell post the whole code. public partial class Form1 : Form { public Form1() { InitializeComponent(); KeyPreview = true; } double first = 0; double second

How to truncate decimals to x places in Swift

对着背影说爱祢 提交于 2019-11-28 07:16:34
问题 In my swift program, I have a really long decimal number (say 17.9384693864596069567 ) and I want to truncate the decimal to a few decimal places (so I want the output to be 17.9384 ). I do not want to round the number to 17.9385 . How can I do this? Help is appreciated! Note: This is not a duplicate because they are using a very old version of swift, before some of these functions were made. Also, they are using floats and integers, whereas I am talking about doubles. And their question

Accurate calculation of CPU usage given in percentage in Linux?

前提是你 提交于 2019-11-28 03:06:16
It's a question which has been asked many times, however there is no well supported answer I could find. Many people suggest the use of top command, but if you run top once (because you have a script for example collecting Cpu usage every 1 second) it will always give the same Cpu usage result ( example 1 , example 2 ). A more accurate way to calculate CPU usage, is by reading the values from /proc/stat , but most of the answers use only the first 4 fields from /proc/stat to calculate it (one example here ). /proc/stat/ has 10 fields per CPU core as of Linux kernel 2.6.33! I also found this

Input string was not in a correct format in double.Parse

五迷三道 提交于 2019-11-28 02:05:03
I am new to C#. I'm trying to make a calculator, but the following error occurred: Input string was not in a correct format. This is the summary of the code: double num1, num2, result; private void button14_Click(object sender, EventArgs e) { num1 = Convert.ToDouble(textBox1.Text); textBox1.Text = String.Empty; num2 = double.Parse(textBox1.Text); **//ERROR OCCURED HERE** result = num1 - num2; } private void button13_Click(object sender, EventArgs e) { num1 = Convert.ToDouble(textBox1.Text); textBox1.Text = String.Empty; num2 = System.Double.Parse(textBox1.Text); **//ERROR OCCURED HERE** result