## Some Swampert are more equal than others

Using wobbotfet, one of the mods of my Discord noticed an oddity: the bot and web version give a different ranking for a Swampert.

Using `1/2/10`

, wobbotfet says it's rank 257. The website said 258.

The answer to that turned out to be that `1/2/10`

and `1/2/11`

actually have the exact same stat product, and the two sites round differently. Something I should look into, maybe, but not a *huge* deal.

Then, in chat, he checked `0/14/12`

and `0/14/13`

. Same thing: they have the exact same stat product. Except:

## 0 14 12

```
CP: 1492
Level: 19
Attack: 121.11401120000001
Defense: 110.05071210000001
HP: 138
Product: 1.839358278542938e+06
```

## 0 14 13

```
CP: 1495
Level: 19
Attack: 121.11401120000001
Defense: 110.05071210000001
HP: 138
Product: 1.839358278542938e+06
```

## Huh?

They have the exact same stat product, but *different CP*. How?

The answer, my friends, is blo- er, rounding.

When calculating CP, the HP/Stamina isn't rounded: for a Swampert with 12 stamina, its stamina stat is `138.00009930000002`

. With 13 stamina it's `138.58237820000002`

.

They both round down to `138`

when calculating the product: this is because that's how HP works in the game. You don't have 138.5 hit points. But when calculating the CP, the `0.58`

does make a difference:

```
FLOOR(Stamina^0.5 * Attack * Def^0.5 / 10)
```

For our 12 stamina this becomes

```
(138.00009930000002^0.5 * 121.11401120000001 * 110.05071210000001^0.5) / 10
= (11.74734435095864 * 121.11401120000001 * 10.49050580763387) / 10
= 14925.55591752906766 / 10
= 1492
```

With one more stamina point it's

```
(138.58237820000002^0.5 * 121.11401120000001 * 110.05071210000001^0.5) / 10
= (11.77210169001270 * 121.11401120000001 * 10.49050580763387) / 10
= 14957.01128628144856 / 10
= 1495
```

And, just like that “where did the extra dollar go” riddle, I've turned one point into three.