subtraction

C++ Can't subtract two strings

大城市里の小女人 提交于 2019-12-10 12:17:34
问题 I want to subtract two strings in this code, but it won't let me do it and gives an operator - error. This code basically tries to separate a full input name into two outputs: first and last names. Please Help! Thank you! #include <iostream> #include <cstdlib> #include <string> using namespace std; string employeeName, firstName, lastName; int pos1, difference; int main() { cout << "Enter your full name: " << endl; getline(cin, employeeName); pos1 = employeeName.find(" "); difference = pos1 -

adding a field without resetting all fields

不打扰是莪最后的温柔 提交于 2019-12-10 11:47:24
问题 Hello I need to have fields be added and taken away with plus and minus buttons. Whenever I add a field it works fine. When I enter something into a field then add another field, the previous field resets. Also, whenever I click the minus button it removes all of the fields. I want it to take one away at a time without resetting the other fields and also I keep getting a Not a Number (NaN) error whenever I click the minus button. Any help is greatly appreciated. I'll show my code below.

Sustract two queries from same table

时间秒杀一切 提交于 2019-12-10 11:35:36
问题 Let's say I have 2 tables: table device is a set of measuring devices, table data is a set of values of different types measured by the devices. Table data = (no, id,value_type,value, dayhour) no is PK, id refer to table device Table device = (id, name) id is PK I currently have a query that will obtain the sum of all values of a specific value_type generated by an id on a specific date, something like: SELECT SUM(cast(a.value as int)),b.name FROM data a INNER JOIN device b ON a.id=b.id AND a

Why does CMP (compare) sometimes sets a Carry Flag in 8086 assembly?

冷暖自知 提交于 2019-12-10 03:21:10
问题 I've been reading around and with the 8086 Instruction Set, it says that a CMP (compare) can set the Carry Flag. I understand that a compare subtracts two operands but I was wondering if anyone can provide an example when that is the case. I just can't grasp the idea of adding a number and a negative number will set the carry flag. I've read into the borrow flag but I just needed an example to clarify my understanding of a compare instruction. Also, I understand that if 3 - 5 = -2 would set

C# wrong subtraction? 12.345 - 12 = 0.345000000000001 [closed]

会有一股神秘感。 提交于 2019-12-10 02:15:59
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I am beginner in C# and I am working with floating point numbers. I need to do subtraction between these two numbers but it does not work. I know it is

How to get rid of additional floating numbers in python subtraction?

跟風遠走 提交于 2019-12-08 21:25:30
def function(): n=123.456 x=int(n) y=n-int(n) print(x,y) result: x= 123 y= 0.45600000000000307 how to get exactly .456 without using library function, n can be any floating number If you know from the outset that the number of decimal places is 3, then: y = round(n - int(n), 3) If you don't know the number of decimal places, then you can work it out, as so: y = round(n - int(n), str(n)[::-1].find('.')) As furas pointed out, you can also use the decimal package: from decimal import Decimal n = Decimal('123.456') y = n - int(n) You can also use the re module: import re def get_decimcal(n: float)

How to get rid of additional floating numbers in python subtraction?

a 夏天 提交于 2019-12-08 04:43:20
问题 def function(): n=123.456 x=int(n) y=n-int(n) print(x,y) result: x= 123 y= 0.45600000000000307 how to get exactly .456 without using library function, n can be any floating number 回答1: If you know from the outset that the number of decimal places is 3, then: y = round(n - int(n), 3) If you don't know the number of decimal places, then you can work it out, as so: y = round(n - int(n), str(n)[::-1].find('.')) As furas pointed out, you can also use the decimal package: from decimal import

How to subtract one bitmap from another in C#/.NET?

百般思念 提交于 2019-12-07 03:48:06
问题 I have two bitmaps, produced by different variations of an algorithm. I'd like to create a third bitmap by subtracting one from the other to show the differences. How can this be done in .NET? I've looked over the Graphics class and all its options, including the ImageAttributes class, and I have a hunch it involves the color matrix or remap tables functionality. Does anyone have a link to some example code, or can point me in the right direction? A google search doesn't reveal much, unless

Matlab - Quickly subtract [1xN] array from [MxN] matrix elements [duplicate]

笑着哭i 提交于 2019-12-06 23:23:53
问题 This question already has answers here : Closed 8 years ago . Possible Duplicates: How to subtract a vector from each row of a matrix? How can I divide each row of a matrix by a fixed row? I have matrix (M1) of M rows and 4 columns. I have another array (M2) of 1 row and 4 columns. I'd like to subtract every element in M1 by its respective column element in M2. In other words, each column of M1 needs to be subtraced by the scalar in the same column position in M2. I could call repmat(M2,M,1)

Java: Easiest Way to Subtract Dates

自古美人都是妖i 提交于 2019-12-06 18:36:31
问题 I have created a class with two fields that need to be dates, start_date and date_passed . I have been researching the best way in java to have dates in a YYYY MM DD format that allows for easy date subtraction, and the ability to "make-up" a date, say in the future for example. Example of what I'd like it to do... library.circulate_book("Chemistry", **start date here**) //actual date or random date library.pass_book("Chemistry", **Date Passed here**) //random date such as 5 days after start