Questions tagged [increment]

DO NOT USE THIS TAG ALONE. Use with a language tag like [javascript] or [python]. Adding one to the value of a variable, generally with the use of an increment operator.

Adding one to the value of a variable, generally with the use of an increment operator.

3520 questions
13
votes
12 answers

Increment a string with letters?

I need to increment a string from.. let's say aaa to zzz and write every incrementation in the console (is incrementation even a word?). It would go something like this: aaa aab aac ... aaz aba abb abc ... abz aca acb And so on. So far I have…
MortenMoulder
  • 6,138
  • 11
  • 60
  • 116
13
votes
6 answers

How to increment number in a file

I have one file with the date like below,let say file name is file1.txt: 2013-12-29,1 Here I have to increment the number by 1, so it should be 1+1=2 like.. 2013-12-29,2 I tried to use 'sed' to replace and must be with variables only.…
Naveen Reddy CH
  • 799
  • 2
  • 13
  • 23
13
votes
2 answers

Increment working very strangely

This program is supposed to give to the last 100 digits of any size factorial. However, there's something weird going on with the counter2++ in main(). counter2 is incremented +1 for each time the loop runs in the main() function (which is 99…
xyz
  • 186
  • 1
  • 3
  • 19
13
votes
2 answers

Possible to safely increment BigInteger in a thread safe way, perhaps with AtomicReference, w/o locking?

A lot of our code is legacy but we are moving to a "Big Data" back-end and I'm trying to evangelize the newer API calls, encourage the use of the latest Spring libraries etc. One of our problems is application layer ID generation. For reasons I…
user447607
  • 5,149
  • 13
  • 33
  • 55
12
votes
3 answers

Why does postfix operator++ have higher precedence than prefix operator++?

Defined this way, we can do neither ++x++ nor ++x--. But on the other hand, both (++x)++ and (++x)-- are useful expressions: (++x)++ increments x by two and returns the value "in the middle", while (++x)-- is essentially equivalent to x+1 but…
12
votes
3 answers

search and replace with regex to increment numbers in Visual Studio Code

I'm currently working on a big svg sprite. The diffrent images are always 2000px apart. What I have is: After regex want this so just adding 2000…
Blue Lovag
  • 693
  • 2
  • 8
  • 18
12
votes
1 answer

How could I add a column to a DataFrame in Pyspark with incremental values?

I have a DataFrame called 'df' like the following: +-------+-------+-------+ | Atr1 | Atr2 | Atr3 | +-------+-------+-------+ | A | A | A | +-------+-------+-------+ | B | A | A | +-------+-------+-------+ | C | A …
jartymcfly
  • 1,945
  • 9
  • 30
  • 51
12
votes
3 answers

Increment a global variable in Bash

Here's a shell script: globvar=0 function myfunc { let globvar=globvar+1 echo "myfunc: $globvar" } myfunc echo "something" | myfunc echo "Global: $globvar" When called, it prints out the following: $ sh zzz.sh myfunc: 1 myfunc: 2 Global: 1 $…
zserge
  • 2,212
  • 2
  • 31
  • 40
12
votes
1 answer

Android: SeekBar Increment Value - How To

My SeekBar (slider) works just fine but, it increments/decrements by one's as I slide my finger but, I want to change the increment value to a constant, such as 5. I tried using slider.incrementProgressBy(5); to do it but, it doesn't work (note:…
headscratch
  • 531
  • 3
  • 15
  • 29
12
votes
3 answers

Is there a pretty way to increment an optional Int?

I want to increment an Int? Currently I have written this : return index != nil ? index!+1 : nil Is there some prettier way to write this ?
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
12
votes
4 answers

Increment Guid in C#

I have an application that has a guid variable which needs to be unique (of course). I know that statistically any guid should just be assumed to be unique, but due to dev/test environment reasons, the same value may be seen multiple times. So when…
Abacus
  • 2,041
  • 1
  • 18
  • 23
12
votes
7 answers

Java Incremental operator query (++i and i++)

I have the following code: public class Book { private static int sample1(int i) { return i++; } private static int sample2(int j) { return ++j; } public static void main(String[] arguments){ int i = 0; …
misguided
  • 3,699
  • 21
  • 54
  • 96
12
votes
1 answer

Incrementing (iterating) between two hex values in Python

I'm learning Python (slowly but surely) but need to write a program that (among other things) increments between two hex values e.g. 30D681 and 3227FF. I'm having trouble finding the best way to do this. So far I have seen a snippet of code on here…
user2188291
  • 149
  • 1
  • 2
  • 9
12
votes
4 answers

Problem with MySql INSERT MAX()+1

I have a single table containing many users. In that table I have column called user_id (INT), which I want increment separately for each person. user_id MUST start at 1 I've prepared a simple example: Showing all…
Chad
  • 2,365
  • 6
  • 26
  • 37
11
votes
9 answers

Precedence of ++ and -- operators in Java

I read from the official tutorial of Java that prefix and postfix ++ -- have different precedences: postfix: expr++ expr-- unary: ++expr --expr +expr -expr ~ ! Operators According to the tutorial, shouldn't this d = 1; System.out.println(d++ +…
zw324
  • 26,764
  • 16
  • 85
  • 118