# Losing decimals

**URL:** https://discourse.processing.org/t/losing-decimals/12442
**Category:** Beginners
**Created:** [July 2, 2019, 11:20am UTC](https://discourse.processing.org/t/losing-decimals/12442 "2019-07-02T11:20:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)
#### Post date: [July 2, 2019, 11:20am UTC](https://discourse.processing.org/t/losing-decimals/12442/1 "2019-07-02T11:20:12Z")

</div>

Hi people!!

I’m getting mad trying to get some points with a lot of decimals…

Maybe this is a stupid question or I’m crazy… but I remember using lot of decimals, with float or double variable types (in java).

I’m using “big numbers” and when I want to get the last values of the decimal part, the value is changing… Better to show the code:

```auto
double[] iz = {458691.451154, 4462621.015578};
double a = 458691.451154;
float f = 458691.451154;

void setup(){
  println("x1000: " +(iz[0]*1000)+" Double: "+iz[0]);  
  println(iz[0],iz[1]);  
  println(" \n THIS IS a: "+a);
  println(" THIS IS f: "+f);
  println(" THIS IS transformed a: "+((a-458690)*100));
  println(" THIS IS transformed2 a: "+((a*100)-(458690*100)));
}

```

And this is the result:

```auto
x1000: 4.586914375E8 Double: 458691.4375
458691.4375 4462621.0
 
 THIS IS a: 458691.4375
 THIS IS f: 458691.44
 THIS IS transformed a: 143.75
 THIS IS transformed2 a: 143.75

```

Don’t know how to get that decimals that I’m losing or why I’m losing them… And why my number finishes with …1.4 **51154** and the printed one finishes with …1.4 **375**

Thanks 💜

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [July 2, 2019, 4:03pm UTC](https://discourse.processing.org/t/losing-decimals/12442/2 "2019-07-02T16:03:00Z")

</div>

Inside “.pde” files, Processing’s preprocessor suffixes any numerical literal containing a point `.` and/or an `e` w/ an `f`, if it doesn’t have 1 already. 🧮

So the PDE would add an `f` to `458691.451154`, thus becoming `458691.451154f`. 🤪

But b/c it’s now a `float` datatype value, the Java compiler would truncate any decimal digits that wouldn’t fit within 4 bytes (32-bit)! ☕

So in order to stop that, just add your own suffix to the literal. 💡  
For datatype `double`, the suffix is `d` or `D`: `458691.451154d`. 😳

---

<div class="post-metadata">

### Author: ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)
#### Post date: [July 3, 2019, 7:14am UTC](https://discourse.processing.org/t/losing-decimals/12442/3 "2019-07-03T07:14:08Z")

</div>

@GoToLoop Mmmm… I tried it with the float but it gave me the same 458691.44 (because of the rounding) so I thought it wasn’t working 🤦‍♂️.

🙃🙃🙃🙃

Thanks!! It works well 😃
