# Number precision

**URL:** <https://forum.kirupa.com/t/number-precision/297176>\
**Category:** flash\
**Created:** [September 26, 2009, 8:31pm UTC](https://forum.kirupa.com/t/number-precision/297176 "2009-09-26T20:31:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![StridBR](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@StridBR](https://forum.kirupa.com/u/StridBR)\
**Post date:** [September 26, 2009, 8:31pm UTC](https://forum.kirupa.com/t/number-precision/297176/1 "2009-09-26T20:31:58Z")

</div>

I’m having this weird problem holding me back on handling collision:

when my object collide, i undo it’s movement (subtract velocities from position, solving the collision) then i reverse its velocity, a pretty basic collision handling for bouncing…, problem is that sometimes the object wont get back to it’s original position (before adding it’s velocities)

here is a basic check i did, which returned a weird response

```auto

if (tag == "player") trace("px: " + x);
            
            x += vx;
            y += vy;
            
            
            x -= vx;
            y -= vy;
                
            if (tag == "player") trace("--->dx: " + x);

```

output:

```auto

--->dx: 200
px: 200
--->dx: 200
px: 200
--->dx: 200
px: 200
--->dx: 200
px: 200
--->dx: 199.95000000000002
px: 199.95000000000002
--->dx: 199.9
px: 199.9
--->dx: 199.85000000000002
px: 199.85000000000002
--->dx: 199.8
px: 199.8
--->dx: 199.75
px: 199.75
--->dx: 199.70000000000002
px: 199.70000000000002
--->dx: 199.65
px: 199.65
--->dx: 199.60000000000002
px: 199.60000000000002
--->dx: 199.55
px: 199.55
--->dx: 199.5
px: 199.5
--->dx: 199.45000000000002
px: 199.45000000000002
--->dx: 199.4
px: 199.4
--->dx: 199.35000000000002
px: 199.35000000000002
--->dx: 199.3
px: 199.3
--->dx: 199.25
px: 199.25
--->dx: 199.20000000000002
px: 199.20000000000002
--->dx: 199.15
px: 199.15
--->dx: 199.10000000000002
px: 199.10000000000002
--->dx: 199.05
px: 199.05
--->dx: 199

```

the object’s position value is reduced by .05 every loop when i add and subtract it’s velocities (same value)

looks like some problem with number precision, any ideas on how to solve this?
