Questions tagged [decrement]

Subtracting one from the value of a variable, generally with the use of an decrement operator.

Subtracting one from the value of a variable, generally with the use of an decrement operator(--).

425 questions
1
vote
2 answers

ON DUPLICATE KEY UPDATE - decrement value in MySQL

The following seems odds to me: INSERT INTO sometable (UNIQUEVALUE,NUMERICVALUE) VALUES ('valuethatexists','100') ON DUPLICATE KEY UPDATE NUMERICVALUE = NUMERICVALUE+VALUES(NUMERICVALUE); Assume your NUMERICVALUE is at 0. The above would change it…
nickdnk
  • 4,010
  • 4
  • 24
  • 43
1
vote
2 answers

iPhone: Problem with incrementing NSNumber & displaying transparent images (UIImageView)

I have a problem with NSNumber: I don't understand how to increment and decrement it! I've tried int with [NSNumber intValue] and so on, but it didn't work!!!! I just want a page counter which can be converted to an NSNumber at the end. My second…
1
vote
1 answer

Timed counter - decrementing of integer(JAVA)

So my problem is that I would like to decrement the Counter integer after every "run". If i put Counter-- in the code(See comment) then I get an error saying "Local variable Counter defined in an enclosing scope must be final or effectively…
Isark
  • 13
  • 4
1
vote
1 answer

R: How to decrease counter in for loop

I would like to do 10 iterations, but sometimes flag is bigger that 1. In this case I must to decrease variable i by 1 and calculate flag again. How to do this decrement? for(i in (1:n)){ flag <- ... # some code if (flag > 1) { …
Nick
  • 1,086
  • 7
  • 21
1
vote
3 answers

Post-Decrement operator

some body please tell me what will be the value of x after(in c language) x=1; x=x--&&++x; I think it should be 0 because x&&++x will give 1 and post decrement will make it 0. But when I entered this on computer result was 1. Why post decrement…
Dhruva Mehrotra
  • 123
  • 1
  • 12
1
vote
1 answer

Swift countDown timer Logic

I'm creating a countdown timer by the day, hour and second. I'm currently storing them in a String array while also converting them into an Int ( using map() ) so that I can countdown/decrement when I make the values into a label. The current…
Lukesivi
  • 2,206
  • 4
  • 25
  • 43
1
vote
4 answers

Decrement operation in Java

So I've just started an IT course and as part of it we're learning to code in Java; I have an assignment for next week, and while I have it figured out, I just have a question as to why it works :P The objective was to write a piece of code that…
LemonyFresh
  • 15
  • 1
  • 4
1
vote
1 answer

Difference between post and pre decrement a char pointer value in c function putchar

I have the following code in C (I'm using tdm-gcc 4.9.1 and Netbeans 8.0.2): #include #include #include char * pr(char * str); int main(void) { char * x; x = pr("Ho Ho Ho!"); return…
1
vote
3 answers

Creating buttons for textbox and assigning click functions on the fly in JQuery

I have the following code to create two buttons (one on the left one on the right) for each texbox on the page. Idea is to make an increment/decrement textbox. Code works fine with one textbox but with 2 or more every button increment/decrements all…
Ergec
  • 11,608
  • 7
  • 52
  • 62
1
vote
1 answer

First index of 2D-Array increases without any explicit increment

I have a for Loop, in which I want to increase the second index of a 2 dimensional Array and want to have a static first index: String[][] grid = new String[7][6]; inject(0); public void inject(int column){ for(int i=5;i>-1;i--){ …
1
vote
2 answers

c++11 atomic decrement of uint64_t cycles at 0

I'm trying to program a simple parallel processing system which should generate N objects to put in a container in a multi-threaded environment. To tell the threads when to stop generating the object I created a simple reverse counter that starts at…
Triskeldeian
  • 590
  • 3
  • 18
1
vote
2 answers

How to count from 10 to 1 in java

For a simple Java program where I want to make the program count from 10 to 1 by incrementing of 2 or 3 or 4 how would I change this code? public class ExampleFor { public static void main(String[] args) { // for(int i = 10; i…
Sempliciotto
  • 107
  • 1
  • 2
  • 6
1
vote
5 answers

what will be the reason behind the output of java code?

Consider the following simple java code public static void main(string args[]) { int x=10; int y; y=x++; y=y--; System.out.println(y); } here output is 10. but actually y variable decrements. but according to me output should be 9. what…
1
vote
0 answers

Using prefix decrement operator (--): variable is 0 but not 0?

Code int main() { int cnt = 5; while(cnt > 0) { printf("cnt = %d %s\n", --cnt, (cnt == 0) ? "cnt == 0" : "cnt != 0"); } return 0; } My Expected Output cnt = 4 cnt != 0 cnt = 3 cnt != 0 cnt = 2 cnt != 0 cnt = 1 cnt != 0 cnt = 0 cnt ==…
Sagi
  • 329
  • 1
  • 4
  • 13
1
vote
5 answers

Why does "- --" and "+ ++" and operate differently?

Decrementation / Incrementation is a basic operation but it's precendence on - -- and + ++ confused me. I'll use decrementation for illustration: I have a set here of different styles of operating between a and b: See it working here #include…
Aesthetic
  • 763
  • 1
  • 14
  • 31