subtraction

Why is 65.12 - 2 not equal to 63.12 in java? [duplicate]

南楼画角 提交于 2019-12-13 06:03:41
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Floating point arithmetic not producing exact results in Java I was recently working on a project when I came across a strange bug. When 2 was subtracted from 65.12 the value was greater (not equal to) 63.12. Here's the simplified code: System.out.println(65.12-2); And the output in the console: 63.120000000000005 I'm not sure why this is the case and if anyone knows a simple fix/workaround that would be great!

Sum, Subtract and Join of multiple mysql table columns

前提是你 提交于 2019-12-13 03:49:09
问题 I have four mysql tables client , transaction , other_loan and payment . I want to get the sum of load_amount and additional from table transaction + sum of amount from other_loan and subtract it to the sum of payment_amount in table payment . How can I achieve it? Result I want: > ID | Name | Amount > 1 | Robin | 8718 > 2 | Reynaldo | 21 > 3 | Leomar | 0 My Tables: transaction > tid | id| date | load_amount | additional > 1 | 1 | 2018-12-01 | 90 | 0 > 2 | 1 | 2018-12-07 | 90 | 0 > 3 | 2 |

Subtract the previous row of data where the id is the same as the row above

若如初见. 提交于 2019-12-13 03:19:52
问题 I have been trying all afternoon to try and achieve this with no success. I have a db in with info on customers and the date that they purchase products from the store. It is grouped by a batch ID which I have converted into a date format. So in my table I now have: CustomerID|Date 1234 |2011-10-18 1234 |2011-10-22 1235 |2011-11-16 1235 |2011-11-17 What I want to achieve is to see the number of days between the most recent purchase and the last purchase and so on. For example: CustomerID|Date

jQuery - calculate element width through subtract pixel from window size

允我心安 提交于 2019-12-13 00:37:32
问题 My goal is to calculate the width of a fixed positioned element (top:0; left:200px;) through subtract 200px from the window size so that it fits the rest of the viewport. Therefore I used the following code but sadly it doesn't work. Hopefully someone of you guys can help me! $(function() { width = ($(window).width() - 100); $("div").css("width", width); })​; 回答1: You don't need to rely on jQuery, actually. There is a simply CSS trick to get this done, by declaring right: 0 on that element.

Difference between “now” and a given date

最后都变了- 提交于 2019-12-12 21:03:24
问题 I need to retrieve all documents in a collection that the difference between new ISODate() and a date field of the document should be greater than a given parameter. I can do this on mongo shell by the query: db.getCollection('tb_registered_app').aggregate( [ { $project: { difference: { $subtract: [ new ISODate(), "$ping_date" ] } } } , { $match: {difference: { "$gte": 300000}} } ] ) I'm trying to use Spring Data MongoDB to execute the same query, with the code: public List<RegisteredApp>

R programming: How can I compute the difference between two cells in a data frame and save them in a new column

时光总嘲笑我的痴心妄想 提交于 2019-12-12 08:09:05
问题 Trying to learn R and am stuck on an autocorrelation example. I want to regress the difference in x against the difference in y. I have x and y in a data frame, and would like the difference of x2 - x1 to be saved in a new column say dx. I have no idea how to go about this. what I have: data1 x y 5 3 8 9 3 1 1 5 . . . . . . what I would like to get: data1.dif x y dx dy 5 3 NA NA 8 9 3 6 3 1 -5 -8 1 5 -2 4 . . . . . . . . 回答1: Use diff , and stick an NA to the beginning of the resulting

How to specify an equation is a spreadsheet program like Gnumeric/Excel?

佐手、 提交于 2019-12-12 03:23:29
问题 I'm doing a rather repetitive subtraction of values from column A and column B, in their respective rows, and I don't want to keep on doing, for example, =A1-B1. Is there a way to set the cell for a formula such that I don't have to specify the row but it'll do the subtraction between column A and B? 回答1: Yes-- in the top cell in, say, row c, enter "=A1-B1" and then hover in the corner until you get the plus mark and drag down. That will apply your equation to every cell you drag to. 回答2:

SQLITE - calculate remaining item quantities

萝らか妹 提交于 2019-12-12 02:34:50
问题 I have a stock table that holds the number of total items for a specific item id/colour: stock_table item_code | colour | stock --------------------------------------------- A | red | 10 A | blue | 8 A | yellow | 5 B | red | 5 B | blue | 0 B | yellow | 15 then I have a table where already ordered items quantities are stored (note that the same item can be found in different orders) orders_table order_id | item_code | colour | ordered_qty -------------------------------------------------------

subtract minutes from calculated time javascript

两盒软妹~` 提交于 2019-12-12 01:24:13
问题 I need to subtract minutes from the calculated time var calculatedTime=11.30;// hours var subtractTime=40;//minutes var diff=calculatedTime - subtractTime;// How to do this ?? How to do this in javascript Thanks 回答1: Try this: function converToMinutes(s) { var c = s.split('.'); return parseInt(c[0]) * 60 + parseInt(c[1]); } function parseTime(s) { return Math.floor(parseInt(s) / 60) + "." + parseInt(s) % 60 } //var minutes = parseTime(EndTIme) - parseTime(StartTime); var timeToSubtract = 40;

How to perform subtraction between two Arraylist items in java

半城伤御伤魂 提交于 2019-12-11 23:47:16
问题 I have two list which have data items of String type.The lists are List<String> all=new ArrayList<String>(); List<String> al2=new ArrayList<String>(); The items are added in the lists from Resultset as:- all.add((rs.getString(3))); all.add((rs.getString(4))); al2.add((rs.getString(3))); al2.add((rs.getString(4))); There are numerical values in the list,I want to subtract the data items from list according to the column retrieved from resultset i.e Subtract(rs.getString(3) of all,rs.getString