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
1 answer

Auto Increment(+) and Decrement(-) button like time picker

Hello I'm trying to get an edit increment decrement, to no avail. I see on Time/Date palette: Time picker, but i want only one box. I'd like an edit like this: Thank You!
1
vote
1 answer

Substraction or decrement random access iterator pointing to begin

Consider following piece of code void foo( bool forwad ) { vector::iterator it, end_it; int dir; it = some_global_vector.begin() + some_position; if( forward ) { dir = 1; it += 1; end_it =…
BeginEnd
  • 334
  • 2
  • 11
1
vote
1 answer

How do I concisely write x = x - 4 unless x is less than 0, in which case x = 0?

I am doing some pagination and can do @next_images_to_paginate += 4 without a problem. But @previous_images_to_paginate -= 4 doesn't because I can get negative numbers. I can't use absolute because I want -1, -2 and -3 to be 0. Something…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
1
vote
1 answer

Increment or decrement array elements by 1

I need some help solving the following competitive programming question. Given array A of size N .now you can make K operations where in each operation you can increase or decrease an element in array by 1. Now beauty of array is frequency of most…
1
vote
4 answers

Why does the following code print 8,5,2 instead of 7,4,1?

I just came across this C question with the following code: int fun(); int main() { for (fun(); fun(); fun()) printf("%d\n", fun()); return 0; } int fun() { int static n = 10; return n--; } I expected the for loop to evaluate…
1
vote
0 answers

Why does the decrementing operator in PHP work in this way?

The following code: $arr = array(1, 2, 3, 4, 5); $i = 5; while($i >= 1){ var_dump($i); var_dump($arr[--$i]); } has the following output: int(5) int(5) int(4) int(4) int(3) int(3) int(2) int(2) int(1) int(1) but if we replace the two lines…
Sharanya Dutta
  • 3,981
  • 2
  • 17
  • 27
1
vote
1 answer

JavaScript: Differences in using "--" vs "- 1" to decrement a for loop's arr.length

I'm curious as to why I get two different results when decrementing the arr.length with arr.length-- and arr.length - 1. I would have thought these would have functioned the same. For example: const numbers = [10, 20, 40, 30, 50] function…
Hezakai
  • 35
  • 4
1
vote
1 answer

Is there a compiler attribute to decrement enumerator-list values/enumeration-constants (in C)?

When you declare a enum, the constant values of the enumerator-list automatically increment. E.g. typedef enum{ TEST0 = 0, TEST_X, // automatically will be 1 TEST_Y, // ...will be 2 ... }test_t; Is there a way to make the enumeration constants…
1
vote
2 answers

Increment and decrement same number TASM

Already made this code that increments the number that I type, but I'm having trouble with making it decrement the same number that I typed. I thought about moving the number from DL into BL back then DEC it and just show it again but it just gives…
1
vote
3 answers

Why do the values of x and y not decrement in this code?

I have been trying to figure out why the output of the code below is 2 2 but can't seem to figure out why. I get that the else statement is getting executed but from what I've read I can't understand why the first print doesn't get…
1
vote
6 answers

Make this increment/decrement work with multiple inputs in jQuery

I am having a bit of trouble selecting an input. Basically, I need the button to increase or decrease the value of a single input contained in the same element. Here's the HTML:
John Peden
  • 657
  • 1
  • 10
  • 24
1
vote
0 answers

make increment and decrement with nfc_manager library flutter

I want to make e-wallet apps using MiFare classic 1K with flutter. also use nfc_manager library I can change the access bit to 887787FF (it change the block of sector to value block that i know). I wanna ask, what step to make increment and…
ilham
  • 61
  • 1
  • 1
  • 5
1
vote
1 answer

Cumulative sum in the decreasing order in R

I have a data table below. Idle_min <- c(1, 2, 3, 5, 6, 8) Freq <- c(16, 11, 5, 7, 3, 1) df <- data.frame(Idle_min, Freq) I want to obtain the cumulative frequency and add it as a new column, but it should be in descending order. That means, the…
Niro Mal
  • 127
  • 7
1
vote
3 answers

How to increment/decrement variable value only once while in a loop?

I need to decrement var "left" by 1 and only once instead of having it go through a loop and decrement if conditions pass true. But conditions are valid only if they are in a loop. How would I do this? let key = e.key.toLowerCase() for (i = 0;…
eyyMinda
  • 25
  • 5
1
vote
1 answer

Is increment stackable? I.e x++++; or (x++)++;

When me and my friend were preparing for exam, my friend said that x+++; is the same as x+=3; It is not true but is x++++; same as x+=1; or is (x++)++;? Could I generalize it? I.e. x++++++++++++++; or ((((((x++)++)++)++)++)++)++; is equivalent to…
JRBros
  • 43
  • 6