# Processing won't allow decimal increment since it is float not int

**URL:** <https://discourse.processing.org/t/processing-wont-allow-decimal-increment-since-it-is-float-not-int/26157>\
**Category:** Coding Questions\
**Created:** [December 12, 2020, 1:46pm UTC](https://discourse.processing.org/t/processing-wont-allow-decimal-increment-since-it-is-float-not-int/26157 "2020-12-12T13:46:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BillyxBonka](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@BillyxBonka](https://discourse.processing.org/u/BillyxBonka)\
**Post date:** [December 12, 2020, 1:46pm UTC](https://discourse.processing.org/t/processing-wont-allow-decimal-increment-since-it-is-float-not-int/26157/1 "2020-12-12T13:46:29Z")

</div>

\<//Increase perSec  
int perSec = 0;  
//Time  
int time = 0;  
//Amount of current milk  
int amount = 0;

//Milk image  
PImage milky;  
//Font setting  
PFont BoldFont;

void setup() {

//Canvas Size  
size(500,500);  
//Fonts  
BoldFont = createFont(“Arial Bold”, 18);  
//Images  
milky = loadImage(“milky.png”);  
//Time  
time = millis();  
}

void draw() {

//Background  
background(0);

//Milky the Milkbox  
//rectMode(CENTER);  
//rect(100,100,64,64);  
imageMode(CENTER);  
image(milky,100,100);

//Prints Current Amount of Milk on Canvas  
textFont(BoldFont);  
text(“We have " + amount + " boxes of milk” ,20,50);

//Store  
text(" Store", 350,200);  
stroke(200,0,0);  
strokeWeight(5);  
line(320,175,320,500);  
line(320,175,500,175);  
line(320,210,500,210);  
//İnek  
stroke(0);  
rectMode(CENTER);  
rect(350,240,50,50);

amount = amount + perSec;  
}

void mousePressed()  
{

// Coordinates print to locate stuff  
print(mouseX,mouseY, " ");

// Increase amount of milk when clicked on milk box.  
if(mouseX \> 78 && mouseX \< 123 && mouseY \> 75 && mouseY \< 128){  
amount = amount+1;  
}  
//Increase “perSec” when Cow is Bought.  
if(mouseX \> 325 && mouseX \< 375 && mouseY \> 215 && mouseY \< 265){  
amount = amount - 100;  
perSec = perSec + 0.10;  
}  
}

> 

On the bottom line, I won’t allow me to set a decimal as an increment, I am pretty new to this thing. Couldn’t think of any solution. I tried creating a new int such as , that would not work either.

---

<div class="post-metadata">

**Author:** ![Divitiacus](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Divitiacus](https://discourse.processing.org/u/Divitiacus)\
**Post date:** [December 12, 2020, 1:53pm UTC](https://discourse.processing.org/t/processing-wont-allow-decimal-increment-since-it-is-float-not-int/26157/2 "2020-12-12T13:53:07Z")

</div>

Integers don’t have decimals. If you create a float variable with float perSec it should work.

> **[float \\ Language (API) \\ Processing 3+](https://processing.org/reference/float.html)**

---

<div class="post-metadata">

**Author:** ![BillyxBonka](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@BillyxBonka](https://discourse.processing.org/u/BillyxBonka)\
**Post date:** [December 12, 2020, 2:29pm UTC](https://discourse.processing.org/t/processing-wont-allow-decimal-increment-since-it-is-float-not-int/26157/3 "2020-12-12T14:29:59Z")

</div>

Oh I see, I set perSec as an integer at the beginning chaning them to Float solved the issue. Thanks!
