subtraction

Anyone know a simple way using java calendar to subtract X days to a date?

Anyone know a simple way using java calendar to subtract X days to a date? Sry not being able to find any function which allows me to directly subtract X days to a date in java, if anyone could point me into the correct direction. ...

Subtraction of MySQL times inconsistent on different machines.

I have a MySQL query structured as follows: SELECT time(c.start_time), time(c.end_time), time(c.end_time) - time(c.start_time) as 'opening_hours' FROM my_shop c; The data in start and end time is 1970-01-01 07:00:00 and 1970-01-01 19:00:00 respectively. On my local machine this this query returns: | 07:00:00 | 19:00:0...

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

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 ...

Implementing floating point subtraction

Hello , all I am trying to implement a floating point arithmetic library and I have trouble understanding the algorithm of subtracting floats. I have implemented addition succesfully and I thought that subtraction was just a special case of it but it seems I am making a mistake somewhere. I am adding the code here just for reference, i...

How can I force subtraction to be signed in Python?

You can skip to the bottom line if you don't care about the background: I have the following code in Python: ratio = (point.threshold - self.points[0].value) / (self.points[1].value - self.points[0].value) Which is giving me wrong values. For instance, for: threshold: 25.0 self.points[0].value: 46 self.points[1].value: 21 I go...

Floating Point Subtraction in C results zero

I have a code wriiten in C which is intended for a 16-bit microcontroller. The code essentially does lot of floating point arithmatic. The arithmatic works fine till the result is positive; but in case of subtraction if the expected result is negative; I get a zero. result = 0.005 - 0.001; is correctly computed as 0.004 result = 0...

Why is subtraction faster than addition in Python?

I was optimising some Python code, and tried the following experiment: import time start = time.clock() x = 0 for i in range(10000000): x += 1 end = time.clock() print '+=',end-start start = time.clock() x = 0 for i in range(10000000): x -= -1 end = time.clock() print '-=',end-start The second loop is reliably faster, anyw...

Subtraction between two sql queries

I have 2 queries in MS SQL that return a number of results using the COUNT function. I can run the the first query and get the first result and then run the other one to get the other result, subtract them and find the results; however is there a way to combine all 3 functions and get 1 overall result As in: run sql1 run sql2 run SQL3...

EmguCV/OpenCV Image addition/subtraction

I am using EmguCV and am trying to subtract 2 images to create a filter similar to AForge .NET's MoveTowards filter. This is what my slightly modified version from the above URL tries to do. Given 2 images, the source and the overlay - it slowly moves the source image towards the overlay. It does this based on the following: result = s...

How to get duration in terms of minutes by subtracting a previous time stamp from the present time in PHP?

How to get duration in terms of minutes by subtracting a previous time stamp from the present time in PHP? The format of time stamp is like 2009-12-05 10:35:28 I want to calculate how many minutes have passed. How to do it? ...

How to calcuate elapsed time in terms of minutes in MySQL

There is a time stamp column/field in a table, and the format is like 2009-12-05 10:35:28, Now I want to get the time in terms of minutes(How many minutes have elapsed) elapsed from then on, how to do it? ...

Subtraction - Order of Evaluation

Is it standard across all languages for the following to yield the value 3? Print(6 - 2 - 1) In other words, are there any languages that will evaluate " 2 - 1 " before " 6 - 2 "? I'd like to make this assumption so that I can quit instinctively inserting parentheses ((6 - 2) - 1). It leave me at risk of LISP nightmares. Thanks ...

All Possible combination for an HEX Value from a given set of chars

Hi all, I am new to python and programming, I am looking for a code, or a sample code that can have a predefined set of hex values and that can find the 3 used values within to generate a certain value. lets say I have a value of : 0x50158A51 this is a 4 byte (32 bit) hex value now i need to find the values which when added or subt...

Efficient Background subtraction with Opencv

Hi, I want to do background subtraction in a video file using Opencv method. Right now i'm able to do background subtraction, but the problem is that i couldn't get the output in color mode. All the output after subtracting the background is coming in grayscale color mode :(. I want to get the color information to the foreground which i...

How to subtract two unsigned ints with wrap around or overflow

There are two unsigned ints (x and y) that need to be subtracted. x is always larger than y. However, both x and y can wrap around; for example, if they were both bytes, after 0xff comes 0x00. The problem case is if x wraps around, while y does not. Now x appears to be smaller than y. Luckily, x will not wrap around twice (only once is...

Mysql auto fill field based on value of two other fields?

I know its possible to autoincrement values, but i was wondering if its possible to fill a field based on the value of two other fields. I have a table with the fields: CREATE TABLE pligg_links ( ... link_votes INT, link_reports INT, link_votes_total INT, ... ); Field link_votes_total should hold the value of field link_vote...

Trouble with javascript subtraction

I'm working on a simple subtraction problem, but unfortunately it keeps returning NaN Here is the function function subtraction(a, b) { var regexp = /[$][,]/g; a = a.replace(regexp, ""); b = b.replace(regexp, ""); var _a = parseFloat(a); var _b = parseFloat(b); return _a - _b; ...

subtract one image from another using openCV

How can I subtract one image from another using openCV? Ps.: I coudn't use the python implementation because I'll have to do it in C++ ...

PHP: simplest way to get the date of the month 6 months prior on the first?

So if today was April 12, 2010 it should return October 1, 2009 Some possible solutions I've googled seem overly complex, any suggestions? ...

NSDecimalNumber subtraction

Hello, I need to subtract 0.5 from number a and set the answer to number b. My code looks like it would work but I'm not sure what I'm doing wrong. The error I get Is on the subtraction line, the error says incompatible type for argument 1 of 'decimalNumberBySubtracting:'. Heres my header: (Note: I only showed the numbers because the h...